public PartialViewResult _AddTask(MyTask task) { task.Date = DateTime.Now; _mytaskService.CreateMyTask(task); ViewBag.CategoryId = task.CategoryId; var list = _mytaskService.GetMyTasks().Where(p => p.CategoryId == task.CategoryId).ToList(); return PartialView("_GetForCategory", list); }
public HttpResponseMessage CreateMyTask(MyTask task) { try { _taskService.CreateMyTask(task); return Request.CreateResponse(HttpStatusCode.OK, task); } catch (BadParametersException e) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, e); } }
public void CreateMyTask(MyTask task) { if (task.Text.Count() == 0) { throw new BadParametersException("Missed a name"); } using (var unitOfWork = _unitOfWorkFactory.NewUnitOfWork()) { unitOfWork.GetRepository<MyTask>().AddItem(task); unitOfWork.Commit(); } }
public PartialViewResult _TaskForm(int id) { var task = new MyTask { CategoryId = id }; return PartialView("_TaskForm", task); }