コード例 #1
0
        public ActionResult AddProjectMember(ProjectMemberViewModel model)
        {
            bool isMemberAdded = false;

            try
            {
                var newProjectMember = PrepareProjectMember(model, true);
                isMemberAdded = _projectEditingPersistence.AddProjectMember(newProjectMember);
                if (isMemberAdded)
                {
                    SetSucceedMessage(string.Format("User '{0}' has been added to project role '{1}' !", newProjectMember.User.UserName, newProjectMember.ProjectRole.Name));
                }
            }
            catch (Exception ex)
            {
                SetErrorMessage("Project member hasn't been created !" + ex.Message);
                //return ShowAlertErrorMessage("Project member hasn't been created !" + ex.Message );
            }

            if (!isMemberAdded)
            {
                return(View(model));//AddProjectMember(model.ProjectId);
            }
            //Stay on edit project if success
            return(Edit(model.ProjectId));
        }
コード例 #2
0
        public List <ProjectMemberViewModel> GetAllProjectMembers()
        {
            var jared = new ProjectMemberViewModel
            {
                Name  = "Jared Holliday",
                Email = "*****@*****.**",
                Role  = "Repo Master"
            };

            var ben = new ProjectMemberViewModel
            {
                Name  = "Ben Frederickson",
                Email = "*****@*****.**",
                Role  = "Work Flow Manager"
            };

            var ian = new ProjectMemberViewModel
            {
                Name  = "Ian Tibe",
                Email = "*****@*****.**",
                Role  = "Unity Manager / Tester"
            };

            List <ProjectMemberViewModel> members = new List <ProjectMemberViewModel>()
            {
                jared,
                ben,
                ian
            };

            return(members);
        }
コード例 #3
0
        public ActionResult Index(int?id)
        {
            // Stop accessing the action if not logged in
            // or account not in the "Staff" role
            if ((HttpContext.Session.GetString("Role") == null) ||
                (HttpContext.Session.GetString("Role") != "Student"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ProjectMemberViewModel projectMemberVM = new ProjectMemberViewModel();

            projectMemberVM.projectMemberList = projectMemberContext.GetAllProjectMembers();

            // BranchNo (id) present in the query string
            if (id != null)
            {
                ViewData["selectedProjectId"] = id.Value;
                projectMemberVM.projectList   = projectMemberContext.GetProjectPM(id.Value);
            }
            else
            {
                ViewData["selectedProjectId"] = "";
            }
            return(View(projectMemberVM));

            //return View();
        }
コード例 #4
0
        public ActionResult AddProjectMember(int id)
        {
            var model = new ProjectMemberViewModel
            {
                ProjectId = id,
                //ProjectRoleId = -1, UserId = -1
            };

            return(View(model));
        }
コード例 #5
0
        public IActionResult Add([FromBody] ProjectMemberViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            projectMemberAppService.Add(viewModel);

            return(Ok());
        }
コード例 #6
0
        public ActionResult Members(string id)
        {
            var project = _projectService.GetProjectByIdentifier(id);

            var viewModel = new ProjectMemberViewModel
            {
                Project        = project,
                UsersToAssign  = GetUsersToAssign(project),
                GroupsToAssign = GetGroupsToAssign(project)
            };

            return(View(viewModel));
        }
コード例 #7
0
ファイル: UserService.cs プロジェクト: thorirv15/VLN2_DODDIDU
        /// <summary>
        /// Get a single project member by project member ID.
        /// </summary>
        /// <param name="projectMemberID">Project Member ID</param>
        /// <returns>'ProjectMemberViewModel'</returns>
        public ProjectMemberViewModel getProjectMemberByProjectMemberID(int projectMemberID)
        {
            ProjectMemberViewModel member = new ProjectMemberViewModel();

            ProjectMember memberFound = (from m in _db._projectMembers
                                         where m.ID == projectMemberID
                                         select m).FirstOrDefault();

            member._userName  = memberFound._userName;
            member._projectID = memberFound._projectID;
            member._id        = memberFound.ID;

            return(member);
        }
コード例 #8
0
        public ActionResult DeleteProjectMember(int?projectMemberID)
        {
            if (projectMemberID != null)
            {
                if (_userService.isProjectMemberInAnyProject(projectMemberID.Value))
                {
                    ProjectMemberViewModel model = new ProjectMemberViewModel();
                    model = _userService.getProjectMemberByProjectMemberID(projectMemberID.Value);

                    if (_userService.isProjectOwner(User.Identity.Name, model._projectID))
                    {
                        return(View(model));
                    }
                }
            }
            return(HttpNotFound());
        }
コード例 #9
0
        private ProjectMember PrepareProjectMember(ProjectMemberViewModel model, bool isNew)
        {
            var projectMember = new ProjectMember
            {
                Id            = isNew ? 0 : model.Id.Value,
                UserId        = model.UserId,
                ProjectId     = model.ProjectId,
                ProjectRoleId = model.ProjectRoleId,
                CreatedDate   = isNew ? DateTime.Now : model.CreatedDate,
                CreatedBy     = isNew ? GetUserName() : model.CreatedBy,
                ModifiedDate  = isNew ? null : model.ModifiedDate,
            };

            //var projectMember = model.MapTo<ProjectMember>()

            return(projectMember);
        }
コード例 #10
0
        public IActionResult Add(ProjectMemberViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToRoute(new
                {
                    controller = "Project",
                    action = "Index"
                }));
            }
            projectMemberAppService.Add(viewModel);

            return(RedirectToRoute(new
            {
                controller = "Project",
                action = "Index"
            }));
        }
コード例 #11
0
        public ActionResult DeleteProjectMemberConfirmed(int?projectMemberID)
        {
            if (projectMemberID != null)
            {
                if (_userService.isProjectMemberInAnyProject(projectMemberID.Value))
                {
                    ProjectMemberViewModel model = new ProjectMemberViewModel();
                    model = _userService.getProjectMemberByProjectMemberID(projectMemberID.Value);

                    if (_userService.isProjectOwner(User.Identity.Name, model._projectID))
                    {
                        _userService.deleteProjectMember(projectMemberID.Value);
                        return(RedirectToAction("DisplayProject" + "/" + model._projectID.ToString()));
                    }
                }
            }
            return(HttpNotFound());
        }
コード例 #12
0
        public void Add(ProjectMemberViewModel viewModel)
        {
            var addCommand = mapper.Map <AddProjectMemberCommand>(viewModel);

            mediatorHandler.SendCommand(addCommand);
        }