async Task Fetch(TodoContext context) { DateTime max = new DateTime(2030, 1, 31); for (DateTime i = new DateTime(2019, 12, 1); i <= max; i = i.AddDays(1)) { TodoDay newDay = new TodoDay() { Day = i, }; CreateInitTasks(newDay); context.Days.Add(newDay); } await context.SaveChangesAsync(); }
void CreateInitTasks(TodoDay day) { if (day.Day.Date == DateTime.Now.Date) { DateTime today = day.Day.Date; TimeSpan now = TimeSpan.FromMinutes((int)DateTime.Now.TimeOfDay.TotalMinutes); day.Items.Add(new TodoItem() { Time = now.Add(TimeSpan.FromMinutes(45)), ReminderTime = today.Add(now.Add(TimeSpan.FromMinutes(15))), Note = "This is your first task note for today!\n\n" + "" + "You can click on it and change its content or planned time." }); day.Items.Add(new TodoItem() { Time = now.Add(TimeSpan.FromMinutes(60)), ReminderTime = today.Add(now.Add(TimeSpan.FromMinutes(30))), Note = "You can also create a new note or move back to the calendar page, using buttons in the right top corner of this view." }); } }