private static void CreateAuthors(AuthorDBContext context) { var author = new Author { Id = Guid.NewGuid(), DateOfBirth = DateTime.Now.AddYears(-30), FirstName = "Jane", LastName = "Seymour", Genre = "Female", Books = new List <Book> { new Book { Title = "Death in Venice", Description = "Fictional Romance" }, new Book { Title = "How to solve a crime", Description = "Fictional" } } }; context.Add(author); var author2 = new Author { Id = Guid.NewGuid(), DateOfBirth = DateTime.Now.AddYears(-40), FirstName = "Tom", LastName = "Clancy", Genre = "Male", Books = new List <Book> { new Book { Title = "Red", Description = "Fictional" }, new Book { Title = "Patriots Games", Description = "Fictional" } } }; context.Add(author2); context.SaveChanges(); }
public AuthorController(AuthorDBContext authorDBContext) { _authorDBContext = authorDBContext; }
private static void AddTestData(AuthorDBContext context) { CreateAuthors(context); }