public ActionResult Accept(int id) { var ts = new TaskService(); if (!ts.IsUserAllowedToDo(id, SessionStorage.User.Id, TaskAction.Accept)) return RedirectToAction("Index", "Home"); ts.AcceptTask(id, SessionStorage.User.Id); return RedirectToAction("Show", new { id }); }
public ActionResult Delete(int id) { var ts = new TaskService(); if (!ts.IsUserAllowedToDo(id, SessionStorage.User.Id, TaskAction.Delete)) return RedirectToAction("Index", "Home"); var task = ts.GetTask(id); if (task == null) return RedirectToAction("Index", "Home"); ts.DeleteTask(id); return RedirectToAction("List", "Task", new {id}); }
public ActionResult Create(Form f) { var ps = new ProjectService(); if (!ps.IsUserAllowedToDo(f.Task.ProjectId, SessionStorage.User.Id, ProjectAction.CreateOrEditTask)) return RedirectToAction("Index", "Home"); if (!ModelState.IsValid) return View(f); var ts = new TaskService(); ts.AddTask(f.ProjectId, f.Task); return RedirectToAction("List", new {id = f.Task.ProjectId}); }
public ActionResult Edit(int id) { var ts = new TaskService(); var task = ts.GetTask(id); if (task == null) return RedirectToAction("Index", "Home"); var ps = new ProjectService(); if (!ps.IsUserAllowedToDo(task.ProjectId, SessionStorage.User.Id, ProjectAction.CreateOrEditTask)) return RedirectToAction("List", new {id = task.ProjectId}); var model = new Form { CostTypes = UIHelper.CreateSelectListFromEnum<CostType>(task.CostType), Statuses = UIHelper.CreateSelectListFromEnum<TaskStatus>(task.Status), Users = (from u in ps.GetProjectTeam(task.ProjectId) select new SelectListItem {Text = u.User.Name, Value = u.UserId.ToString()}). ToList(), Task = task, ProjectId = task.ProjectId, ProjectName = task.Project.Name }; return View(model); }
public ActionResult Show(int id) { var ts = new TaskService(); var task=ts.GetTask(id); var vm = new Show { Task = task, ProjectId = task.ProjectId, ProjectName = task.Project.Name, CanUserAcceptTask = !task.ResponsibleId.HasValue, AssignedForCurrentUser = task.ResponsibleId.GetValueOrDefault() == SessionStorage.User.Id }; return View(vm); }
public ActionResult PostComment(int id, string message) { var ts = new TaskService(); ts.PostComment(id, message, SessionStorage.User.Id); return RedirectToAction("Show", new {id = id}); }
public ActionResult List(int id, string show = "active") { var ps = new ProjectService(); if (!ps.IsUserAllowedToDo(id, SessionStorage.User.Id, ProjectAction.SeeTaskList)) return RedirectToAction("Index", "Home"); var project = ps.GetProjectById(id); var tasks = new TaskService().GetTasksForProject(id, show); var vm = new List { TaskFilter = show, Tasks = tasks, ProjectName = project.Name, ProjectId = id, CanUserEditTasks = ps.GetProjectById(id).Team.Any( t => t.UserId == SessionStorage.User.Id && t.AccessLevel == AccessLevel.ProjectManager) }; return View(vm); }
public ActionResult Edit(Form t) { var ts = new TaskService(); var task = ts.GetTask(t.Task.Id); if (task == null) return RedirectToAction("Index", "Home"); var ps = new ProjectService(); if (!ps.IsUserAllowedToDo(t.Task.ProjectId, SessionStorage.User.Id, ProjectAction.CreateOrEditTask)) return RedirectToAction("List", new { id = task.Id }); if (!ModelState.IsValid) return View(t); ts.UpdateTask(t.Task); this.SetTempMessage(Resources.Task_Updated, "success"); return RedirectToAction("List", new {id = t.Task.ProjectId}); }