コード例 #1
0
 public ActionResult Create(TaskDay taskday)
 {
     if (ModelState.IsValid)
     {
         taskdayRepository.InsertOrUpdate(taskday);
         taskdayRepository.Save();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #2
0
        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);
        }