|
|
|
@ -38,16 +38,21 @@ namespace Acme.BookStore
|
|
|
|
|
{
|
|
|
|
|
private readonly IRepository<Book, Guid> _bookRepository;
|
|
|
|
|
private readonly IGuidGenerator _guidGenerator;
|
|
|
|
|
private readonly ICurrentTenant _currentTenant;
|
|
|
|
|
|
|
|
|
|
public BookStoreDataSeedContributor(
|
|
|
|
|
IRepository<Book, Guid> bookRepository,
|
|
|
|
|
IGuidGenerator guidGenerator)
|
|
|
|
|
IGuidGenerator guidGenerator,
|
|
|
|
|
ICurrentTenant currentTenant)
|
|
|
|
|
{
|
|
|
|
|
_bookRepository = bookRepository;
|
|
|
|
|
_guidGenerator = guidGenerator;
|
|
|
|
|
_currentTenant = currentTenant;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task SeedAsync(DataSeedContext context)
|
|
|
|
|
{
|
|
|
|
|
using (_currentTenant.Change(context?.TenantId))
|
|
|
|
|
{
|
|
|
|
|
if (await _bookRepository.GetCountAsync() > 0)
|
|
|
|
|
{
|
|
|
|
@ -66,6 +71,7 @@ namespace Acme.BookStore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
````
|
|
|
|
|
|
|
|
|
|
* `IDataSeedContributor` defines the `SeedAsync` method to execute the **data seed logic**.
|
|
|
|
|