|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
@ -65,6 +70,7 @@ namespace Acme.BookStore
|
|
|
|
|
await _bookRepository.InsertAsync(book);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
````
|
|
|
|
|
|
|
|
|
|