示例#1
0
        public ActionResult Invite(int id)
        {
            var ps = new ProjectService();
            var usersInfo = ps.GetUsersForInviteToProject(id);

            ViewBag.Id = id;
            return View(usersInfo);
        }
示例#2
0
        public ActionResult Create(CreateForm p)
        {
            var ws = new WorkspaceService();
            if (!ws.IsUserCanInteractWithWorkspace(SessionStorage.User.Id, p.WorkspaceId))
                return RedirectToAction("Index", "Workspace");

            if (!ModelState.IsValid) return View(p);

            int projectId = new ProjectService().CreateProject(p.Name, p.WorkspaceId, SessionStorage.User.Id,
                                                               p.Description);

            return RedirectToAction("Show", "Project", new { id = projectId });
        }
示例#3
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});
        }
示例#4
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);
        }
示例#5
0
        public ActionResult TeamMate(TeamMate tm, string action)
        {
            var ps = new ProjectService();
            if (!ps.IsUserAllowedToDo(tm.ProjectId, SessionStorage.User.Id, ProjectAction.EditTeam))
                return RedirectToAction("Index", "Home");

            if (action == "update")
            {
                ps.UpdateTeamMate(tm);
                this.SetTempMessage(Resources.Global_ChangesSaved, "success");
            }
            if (action == "remove")
            {
                ps.RemoveTeamMate(tm);
                this.SetTempMessage(Resources.Project_Team_UserRemoved, "success");
            }

            return RedirectToAction("Team", new {id = tm.ProjectId});
        }
示例#6
0
        public ActionResult Team(int id)
        {
            var ps = new ProjectService();
            var project = ps.GetProjectById(id);
            if (project == null || !ps.IsUserCanSeeProject(SessionStorage.User.Id, id))
                return RedirectToAction("Index", "Workspace");

            var vm = new TeamList
                         {
                             ProjectId = id,
                             ProjectName = project.Name,
                             Team = from t in project.Team
                                    select
                                        new TeamList.TeamMate
                                            {UserId = t.UserId, Username = t.User.Name, UserLevel = t.AccessLevel},
                             CanChangePM = project.Workspace.Owner.Id == SessionStorage.User.Id,
                             CanEditTeam =
                                 project.Team.Any(
                                     t =>
                                     t.AccessLevel == Models.Domain.AccessLevel.ProjectManager &&
                                     t.UserId == SessionStorage.User.Id)
                         };

            return View(vm);
        }
示例#7
0
        public ActionResult Show(int id)
        {
            var ps = new ProjectService();
            var project = ps.GetProjectById(id);
            if (project != null && ps.IsUserCanSeeProject(SessionStorage.User.Id, id))
                return View(project);

            return RedirectToAction("Index", "Workspace");
        }
示例#8
0
        public ActionResult Shared()
        {
            var projects=new ProjectService().GetSharedProjectsForUser(SessionStorage.User.Id);

            return View(new Shared {Projects = projects});
        }
示例#9
0
        public ActionResult Report(int id)
        {
            var ps = new ProjectService();
            if (!ps.IsUserAllowedToDo(id, SessionStorage.User.Id, ProjectAction.ViewReport))
                return RedirectToAction("Index", "Home");

            var project = ps.GetProjectById(id);
            Report model = new Report
                               {
                                   ProjectId = id,
                                   ProjectName = project.Name,
                                   BeginDate = DateTime.UtcNow.AddDays(-DateTime.UtcNow.Day + 1)
                               };
            model.EndDate =
                model.BeginDate.AddDays(DateTime.DaysInMonth(model.BeginDate.Year, model.BeginDate.Month) -
                                        model.BeginDate.Day);
            //we want here 1st dy of the  month and the last day of the month
            model.Tasks = ps.GetCompletedTasksInRange(model.BeginDate, model.EndDate);

            return View(model);
        }
示例#10
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);
        }
示例#11
0
        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);
        }
示例#12
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});
        }
示例#13
0
        /// <summary>
        /// This method suggests list of users which can be invited to project.
        /// This list consists of project pm, others programmers from the same workspace
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetUsersForInviteToProject(int projectId)
        {
            var ps = new ProjectService();
            var proj = ps.GetProjectById(projectId);
            int workspaceId = proj.Workspace.Id;
            var currentProjectTeam = ps.GetProjectTeam(projectId);
            var curProjectTeam = currentProjectTeam.ToDictionary(t => t.User.Id, t => t.User.Name);

            var usersInfo = new WorkspaceService().GetUsersInWorkspaceProjects(workspaceId);

            usersInfo = usersInfo.Except(curProjectTeam).ToDictionary(t => t.Key, t => t.Value);

            return usersInfo;
        }