public PtTask AddNewTask(PtNewTask newTask) { var item = context.PtItems.Single(i => i.Id == newTask.ItemId); PtTask task = new PtTask { Id = item.Tasks.Max(t => t.Id) + 1, Title = newTask.Title, Completed = false, DateCreated = DateTime.Now, DateModified = DateTime.Now }; item.Tasks.Insert(0, task); return(task); }
public PtTask UpdateTask(PtUpdateTask updateTask) { var item = context.PtItems.Single(i => i.Id == updateTask.ItemId); var oldTask = item.Tasks.Single(t => t.Id == updateTask.Id); var idx = item.Tasks.FindIndex(t => t.Id == updateTask.Id); PtTask uTask = new PtTask { Id = oldTask.Id, Title = updateTask.Title, Completed = updateTask.Completed, DateCreated = oldTask.DateCreated, DateModified = DateTime.Now, DateEnd = oldTask.DateEnd, DateStart = oldTask.DateStart }; item.Tasks[idx] = uTask; return(uTask); }
public void DeleteTaskHandler(PtTask t) { RpsTasksRepo.DeleteTask(t.Id, Item.Id); TaskItems.Remove(t); }