public IEnumerable <TaskItem> GetTasks() { if (context.TaskItems.Count() == 0) { context.TaskItems.Add(new TaskItem { ID = null, DateCreated = DateTime.Now.AddDays(-24), Title = "Wake up", Description = "First sample task", DueDate = DateTime.Now.AddDays(7) }); context.TaskItems.Add(new TaskItem { ID = null, DateCreated = DateTime.Now.AddDays(-10), Title = "Do your best", Description = "Second sample task", DueDate = DateTime.Now.AddDays(14) }); context.TaskItems.Add(new TaskItem { ID = null, DateCreated = DateTime.Now, Title = "Go to sleep", Description = "Third sample task", DueDate = DateTime.Now.AddDays(21) }); context.SaveChanges(); } return(context.TaskItems.ToList()); }
public void CreateTaskList(TaskList taskToCreate) { _context.Add(taskToCreate); _context.SaveChanges(); }