Example #1
0
        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});
        }
Example #2
0
        public ActionResult Create(int id)
        {
            var ps = new ProjectService();
            if (!ps.IsUserAllowedToDo(id, SessionStorage.User.Id, ProjectAction.CreateOrEditTask))
                return RedirectToAction("Index", "Home");

            var model = new Form
                            {
                                CostTypes = UIHelper.CreateSelectListFromEnum<CostType>(),
                                Statuses = UIHelper.CreateSelectListFromEnum<TaskStatus>(),
                                Users = (from u in ps.GetProjectTeam(id)
                                         select new SelectListItem {Text = u.User.Name, Value = u.UserId.ToString()}).
                                    ToList(),
                                Task = new Task {ProjectId = id},
                                ProjectName = ps.GetProjectById(id).Name,
                                ProjectId = id,
                                IsCreation = true
                            };
            model.Users.Add(new SelectListItem {Text = "Free assigning", Value = "0"});

            return View(model);
        }
Example #3
0
        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);
        }
Example #4
0
        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});
        }