public ActionResult AddNewTask(TaskViewModel task, int projectId, int userId) { task.isChild = false; task.ParentTask = null; task.Project = projectService.GetProjectById(projectId).GetMvcEntity(); task.User = userMapper.ToMvcUser(userService.GetUserEntity(userId)); task.Status = Status.New; ViewBag.projectId = projectId; ViewBag.userId = userId; try { if (ModelState.IsValid) { if (task.Deadline > DateTime.Now) { taskService.CreateTask(taskMapper.ToBllTask(task)); new MailController().NewTask(task.User, task.Description).Deliver(); return RedirectToAction("Index"); } ViewBag.Message = "Deadline must be somewhere in future"; } return View(task); } catch { ViewBag.Message = "Some Error,try again"; return View(task); } }
// GET: Task/Create public ActionResult AddNewTask(int projectId,int userId) { var task = new TaskViewModel(); ViewBag.projectId = projectId; ViewBag.userId = userId; return View(task); }
public TaskEntity ToBllTask(TaskViewModel task) { var parentTask = task.ParentTask; int? pId; if (parentTask == null) pId = null; else pId = task.ParentTask.Id; return new TaskEntity() { Id = task.Id, Deadline = task.Deadline, Description = task.Description, UserId = task.User==null?default(int):task.User.Id, ProjectId = task.Project==null?default(int):task.Project.Id, isChild = task.isChild, StatusId = (int)task.Status, ParentTaskId = pId }; }
public ActionResult AddSubTask(int parentId,TaskViewModel task) { ViewBag.ParentId = parentId; try { if(task.Deadline>DateTime.Now) if (taskService.AddSubtask(parentId, taskMapper.ToBllTask(task))) { var task1 = taskMapper.ToMvcTask(taskService.GetTaskById(parentId)); new MailController().NewTask(task1.User, task1.Description).Deliver(); return RedirectToAction("Index"); } else { ViewBag.Message = "Deadline of subtask bigger then Parent task"; return View(task); } else { ViewBag.Message = "Deadline must be in future"; return View(task); } } catch { ViewBag.Message = "Deadline of subtask bigger then Parent task"; return View(task); } }
public ActionResult ChangeStatus(TaskViewModel task) { try { if (taskService.ChangeStatus(task.Id, (int)task.Status)) { var task1 = taskMapper.ToMvcTask(taskService.GetTaskById(task.Id)); new MailController().StatusChanges(task1.User, task1.Description).Deliver(); return RedirectToAction("Index"); } return View(task); } catch { return View(task); } }