Example #1
0
 public void CreateSubtask(Subtask subtask)
 {
     if (subtask.Text == String.Empty)
     {
         throw new BadParametersException("Missed a name");
     }
     using (var unitOfWork = _unitOfWorkFactory.NewUnitOfWork())
     {
         unitOfWork.GetRepository<Subtask>().AddItem(subtask);
         unitOfWork.Commit();
     }
 }
 public HttpResponseMessage CreateSubtask(Subtask subtask)
 {
     try
     {
         _subtaskService.CreateSubtask(subtask);
         return Request.CreateResponse(HttpStatusCode.OK, subtask);
     }
     catch (BadParametersException e)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, e);
     }
 }
 public ActionResult Edit(Subtask subtask)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _subtaskService.SetSubtaskName(subtask.Id, subtask.Text);
             return RedirectToAction("Details", "Tasks", new { id = subtask.TaskId.ToString() });
         }
         catch (BadParametersException e)
         {
             return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         }
         catch (InstanceNotFoundException e)
         {
             return HttpNotFound();
         }
     }
     return View(subtask);
 }
 public PartialViewResult _SubtasksForm(int id)
 {
     var task = new Subtask { TaskId = id };
     return PartialView("_SubtasksForm", task);
 }
 public PartialViewResult _AddSubtask(Subtask subt)
 {
     try
     {
         _subtaskService.CreateSubtask(subt);
     }
     catch (BadParametersException e)
     {
         //помилка
     }
     ViewBag.TaskId = subt.TaskId;
     var list = _subtaskService.GetSubtask().Where(p => p.TaskId == subt.TaskId).ToList();
     return PartialView("_GetSubtaskFor", list);
 }