Esempio n. 1
0
 public void InsertOrUpdate(TaskDetail taskdetail)
 {
     if (taskdetail.Id == default(int))
     {
         // New entity
         context.TaskDetails.Add(taskdetail);
     }
     else
     {
         // Existing entity
         context.Entry(taskdetail).State = EntityState.Modified;
     }
 }
 public void InsertOrUpdate(TaskDetail taskdetail)
 {
     if (taskdetail.Id == default(int))
     {
         // New entity
         context.TaskDetails.Add(taskdetail);
     }
     else
     {
         // Existing entity
         context.Entry(taskdetail).State = EntityState.Modified;
     }
 }
 public bool SaveTask(TaskDetail task)
 {
     DateTime targetDay = new DateTime(task.Starts.Year, task.Starts.Month, task.Starts.Day);
     TaskDay day = _taskDay.All.FirstOrDefault<TaskDay>(_ => _.Day == targetDay);
     if (day == null)
     {
         day = new TaskDay
         {
             Day = new DateTime(task.Starts.Year, task.Starts.Month, task.Starts.Day),
             Tasks = new List<TaskDetail>()
         };
         _taskDay.InsertOrUpdate(day);
         _taskDay.Save();
         task.ParentTaskId = day.Id;
     }
     else
     {
         task.ParentTaskId = day.Id;
         task.ParentTask = null;
     }
     _taskDetail.InsertOrUpdate(task);
     _taskDetail.Save();
     return true;
 }