public ActionResult Create(Task task)
 {
     if (ModelState.IsValid) {
         taskRepository.InsertOrUpdate(task);
         taskRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleStatus = statusRepository.All;
         return View();
     }
 }
 public void InsertOrUpdate(Task task)
 {
     if (task.TaskId == default(int)) {
         // New entity
         task.CreatedOn = task.ModifiedOn = DateTime.UtcNow;
         context.Tasks.Add(task);
     } else {
         // Existing entity
         task.ModifiedOn = DateTime.UtcNow;
         context.Entry(task).State = EntityState.Modified;
     }
 }