Beispiel #1
0
        public ActionResult Create(int id)
        {
            var ws = new WorkspaceService();
            if (!ws.IsUserCanInteractWithWorkspace(SessionStorage.User.Id, id))
                return RedirectToAction("Index", "Workspace");

            return View(new CreateForm {WorkspaceId = id});
        }
Beispiel #2
0
        public ActionResult Index()
        {
            var cs = new WorkspaceService();
            int userId = SessionStorage.User.Id;
               // int workspaceId = cs.GetDefaultWorkspaceForUser(userId);

            return View(cs.GetWorkspacesForUser(userId));
        }
Beispiel #3
0
 public ActionResult Edit(Form form)
 {
     var ws = new WorkspaceService();
     if (ws.IsUserCanInteractWithWorkspace(SessionStorage.User.Id, form.Workspace.Id))
     {
         ws.UpdateWorkspace(form.Workspace);
         this.SetTempMessage("Workspace has been updated.", "success");
     }
     return RedirectToAction("Index");
 }
Beispiel #4
0
        public ActionResult Edit(int id)
        {
            var ws = new WorkspaceService();
            var workspace = ws.GetWorkspace(id);
            if (workspace != null && ws.IsUserCanInteractWithWorkspace(SessionStorage.User.Id, id))
                return View(new Form() {Workspace = workspace, IsEditing = true});

            this.SetTempMessage("You can't see this page.", "error");
            return RedirectToAction("Index");
        }
Beispiel #5
0
 public ActionResult Delete(int id)
 {
     var ws = new WorkspaceService();
     if (ws.IsUserCanInteractWithWorkspace(SessionStorage.User.Id, id))
     {
         ws.DeleteWorkspace(id);
         this.SetTempMessage("Workspace has been deleted.", "success");
     }
     return RedirectToAction("Index");
 }
Beispiel #6
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 });
        }
Beispiel #7
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;
        }