public ActionResult Create(TaskCreateViewModel model) { if (this.ModelState.IsValid) { Task task = model.ToEntity(); this.Storage.GetRepository <ITaskRepository>().Create(task, this.GetCurrentUserName()); this.Storage.Save(); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult Post(TaskCreateViewModel model) { if (this.ModelState.IsValid) { Task task = model.ToEntity(); var repo = this.Storage.GetRepository <ITaskRepository>(); repo.Create(task, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true })); } return(BadRequest(new { success = false })); }