private static async Task SeedToDoItemsAsync(ToDoListDbContext toDoBbContext) { if (toDoBbContext.ToDoItem.Any()) { return; } var toDoList = toDoBbContext.ToDoList.FirstOrDefault(); var toDoItems = new List <ToDoItem>() { new ToDoItem() { Description = "First ToDo Item", ToDoList = toDoList, Status = 0, DeadLine = DateTime.UtcNow.AddDays(30), CreatedDate = DateTime.UtcNow, DataStatus = 0 }, new ToDoItem() { Description = "Second ToDo Item", ToDoList = toDoList, Status = 0, DeadLine = DateTime.UtcNow.AddDays(30), CreatedDate = DateTime.UtcNow, DataStatus = 0 }, new ToDoItem() { Description = "Third ToDo Item", ToDoList = toDoList, Status = 0, DeadLine = DateTime.UtcNow.AddDays(30), CreatedDate = DateTime.UtcNow, DataStatus = 0 }, }; toDoBbContext.ToDoItem.AddRange(toDoItems); await toDoBbContext.SaveChangesAsync(); }
private static async Task SeedToDoListAsync(ToDoListDbContext toDoBbContext) { if (toDoBbContext.ToDoList.Any()) { return; } var user = toDoBbContext.User.FirstOrDefault(); if (user != null) { var toDoList = new List <ToDoList>() { new ToDoList() { Name = "First List", User = user, CreatedDate = DateTime.UtcNow, DataStatus = 0 }, new ToDoList() { Name = "Second List", User = user, CreatedDate = DateTime.UtcNow, DataStatus = 0 }, new ToDoList() { Name = "Third list", User = user, CreatedDate = DateTime.UtcNow, DataStatus = 0 }, }; toDoBbContext.ToDoList.AddRange(toDoList); await toDoBbContext.SaveChangesAsync(); } }