using System; using System.Threading.Tasks; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories; using Volo.Abp.Guids; namespace Acme.BookStore { public class BookStoreTestDataSeedContributor : IDataSeedContributor, ITransientDependency { private readonly IRepository _bookRepository; private readonly IGuidGenerator _guidGenerator; public BookStoreTestDataSeedContributor( IRepository bookRepository, IGuidGenerator guidGenerator) { _bookRepository = bookRepository; _guidGenerator = guidGenerator; } public async Task SeedAsync(DataSeedContext context) { await _bookRepository.InsertAsync( new Book { Id = _guidGenerator.Create(), Name = "Test book 1", Type = BookType.Fantastic, PublishDate = new DateTime(2015, 05, 24), Price = 21 } ); await _bookRepository.InsertAsync( new Book { Id = _guidGenerator.Create(), Name = "Test book 2", Type = BookType.Science, PublishDate = new DateTime(2014, 02, 11), Price = 15 } ); } } }