Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public void DeleteTaskHandler(PtTask t)
 {
     RpsTasksRepo.DeleteTask(t.Id, Item.Id);
     TaskItems.Remove(t);
 }