示例#1
0
        public void ProjectRequest(int idProject, string action)
        {
            int idUser = _userTable.GetUserId(HttpContext.User.Identity.Name);
            var up     = _projectTable.GetUserProjectByIds(idUser, idProject);

            if (action == "confirm")
            {
                up.IdRole = (int)Roles.ProjectUser;
                _projectTable.UpdateUserProject(up);
            }
            else
            {
                _projectTable.DeleteUserProject(up);
            }
        }
示例#2
0
        public void ChangeRole(int idUser, int idProject)
        {
            var idSignedUser = _userTable.GetUserId(HttpContext.User.Identity.Name);

            if (_projectTable.UserCanControlProject(idSignedUser, idProject))
            {
                var up = _projectTable.GetUserProjectByIds(idUser, idProject);
                if (up.IdRole == (int)Roles.ProjectLeader)
                {
                    up.IdRole = (int)Roles.ProjectUser;
                    var msg = "You have been demoted in project " + _projectTable.GetProjectById(idProject).Name;
                    _notificationTable.NotifyUser(idUser, msg);
                }
                else if (up.IdRole == (int)Roles.ProjectUser)
                {
                    up.IdRole = (int)Roles.ProjectLeader;
                    var msg = "You have been promoted in project " + _projectTable.GetProjectById(idProject).Name;
                    _notificationTable.NotifyUser(idUser, msg);
                }
                _projectTable.UpdateUserProject(up);
            }
        }