public IActionResult Create(TaskViewModel model) {
     if (ModelState.IsValid) {
         _dataAccess.AddTask(model.ToModel(_dataAccess));
         return RedirectToAction("Index");
     }
     return View(model);
 }
 public IActionResult Edit(int id)
 {
     var dbTask = _dataAccess.GetTask(id);
     var model = new TaskViewModel {
         Id = dbTask.Id,
         Name = dbTask.Name,
         Description = dbTask.Description,
         ActivityId = dbTask.Activity.Id,
         ActivityName = dbTask.Activity.Name,
         StartDateTime = dbTask.StartDateTimeUtc,
         EndDateTime = dbTask.EndDateTimeUtc
     };
     return View(model);
 }
        public IActionResult Delete(int id) {

            var dbTask = _dataAccess.GetTask(id);
            if (dbTask == null) {
                return new HttpStatusCodeResult(404);
            }

            var model = new TaskViewModel {
                Id = dbTask.Id,
                Name = dbTask.Name,
                StartDateTime = dbTask.StartDateTimeUtc,
                EndDateTime = dbTask.EndDateTimeUtc
            };

            return View(model);
        }
        public async Task<IActionResult> Edit(TaskViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _dataAccess.UpdateTask(model.ToModel(_dataAccess));
                if (ViewBag.ActivityId != null)
                {
                    return RedirectToAction("Index", new { activityId = ViewBag.ActivityId });
                }
                else
                {
                    return RedirectToAction("Index");
                }                
            }

            return View(model);
        }