public JsonResult CreateTask(TaskViewModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, errors = ModelState.Keys.SelectMany(i => ModelState[i].Errors).Select(m => m.ErrorMessage) })); } ToDoTask task = new ToDoTask() { ToDoListID = 1, ToDoTaskName = model.TaskName, SortOrder = model.SortOrder }; var newTask = _taskListManager.Add(task); var data = _taskListManager.GetAll(); return(Json(data, JsonRequestBehavior.AllowGet)); }