using System; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Volo.Abp.Threading; namespace Acme.BookStore { public class BookStoreTestDataBuilder : ITransientDependency { private readonly IIdentityDataSeeder _identityDataSeeder; private readonly IRepository _bookRepository; public BookStoreTestDataBuilder( IIdentityDataSeeder identityDataSeeder, IRepository bookRepository) { _identityDataSeeder = identityDataSeeder; _bookRepository = bookRepository; } public void Build() { AsyncHelper.RunSync(BuildInternalAsync); } public async Task BuildInternalAsync() { await _identityDataSeeder.SeedAsync("1q2w3E*"); await _bookRepository.InsertAsync( new Book { Id = Guid.NewGuid(), Name = "Test book 1", Type = BookType.Fantastic, PublishDate = new DateTime(2015, 05, 24), Price = 21 } ); await _bookRepository.InsertAsync( new Book { Id = Guid.NewGuid(), Name = "Test book 2", Type = BookType.Science, PublishDate = new DateTime(2014, 02, 11), Price = 15 } ); } } }