public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaskTransferModel taskDto = _taskService.GetTask(id); if (taskDto == null) { return(HttpNotFound()); } var task = Mapper.Map <TaskTransferModel, TaskViewModel>(taskDto); return(View(task)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaskTransferModel taskDto = _taskService.GetTask(id); if (taskDto == null) { return(HttpNotFound()); } ViewBag.UserList = GetUsers(); ViewBag.TaskUsers = GetUsersForTask(id); var task = Mapper.Map <TaskTransferModel, TaskViewModel>(taskDto); return(View(task)); }
public void SaveTask(TaskTransferModel taskDTO) { if (taskDTO.Name.Length > 25) { throw new ValidationException($"The length of {nameof(taskDTO.Name)} must be less then 25" , nameof(taskDTO.Name)); } if (taskDTO.Description.Length > 255) { throw new ValidationException($"The length of {nameof(taskDTO.Description)} must be less then 25" , nameof(taskDTO.Description)); } var task = Mapper.Map <TaskTransferModel, Task>(taskDTO); Database.Tasks.Create(task); Database.Save(); }
public void UpdateTask(TaskTransferModel taskDTO) { if (taskDTO.Name.Length > 25) { throw new ValidationException($"The length of {nameof(taskDTO.Name)} must be less then 25" , nameof(taskDTO.Name)); } if (taskDTO.Description.Length > 255) { throw new ValidationException($"The length of {nameof(taskDTO.Description)} must be less then 25" , nameof(taskDTO.Description)); } var task = Database.Tasks.Get(taskDTO.TaskId); if (task != null) { Mapper.Map(taskDTO, task); Database.Save(); } }
public ActionResult Delete(int?id, bool?saveChangesError = false) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator."; } TaskTransferModel taskDto = _taskService.GetTask(id); if (taskDto == null) { return(HttpNotFound()); } var task = Mapper.Map <TaskTransferModel, TaskViewModel>(taskDto); return(View(task)); }