示例#1
0
        // GET: GroupUser/Delete/5
        public async Task <ActionResult> Delete(string userGroupId)
        {
            string accessToken      = Session["MicrosoftAccessToken"] as string;
            var    roleTypeService  = new RoleTypeService(accessToken);
            var    userService      = new UserService(accessToken);
            var    userGroupService = new UserGroupService(accessToken);

            var allRoleTypes = await roleTypeService.GetAllRoleTypes();

            var userGroup = await userGroupService.GetUserGroupById(userGroupId);

            var user = await userService.GetUserById(userGroup.UserId);

            GroupUserModel guModel = new GroupUserModel();

            guModel.UserEmail   = user.Email;
            guModel.RoleTypeId  = userGroup.RoleTypeId;
            guModel.RoleName    = allRoleTypes.Single(r => r.Id == userGroup.RoleTypeId).RoleName;
            guModel.UserGroupId = userGroup.Id;

            ViewBag.GroupId = userGroup.GroupId;

            GroupService groupService = new GroupService(accessToken);
            string       groupName    = await groupService.GroupNameByGroupId(userGroup.GroupId);

            if (await AccessAdmin(userGroup.GroupId) && !userGroup.IsUserDefaultGroup)
            {
                return(View(guModel));
            }
            else
            {
                return(View("AccessDenied"));
            }
        }
示例#2
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvUserGroup_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            _editId = Convert.ToInt32(dgvUserGroup.CurrentRow.Cells["UserGroupId"].Value);

            UserGroup userGroup = _userGroupService.GetUserGroupById(_editId);

            txtUserName.Text  = userGroup.User.Name;
            UserId            = userGroup.UserId;
            txtGroupName.Text = userGroup.Group.Name;
            GroupId           = userGroup.GroupId;
            btnAdd.Enabled    = false;
            btnUpdate.Enabled = true;
        }
示例#3
0
        public async Task <ActionResult> Delete(string userGroupId, GroupUserModel groupUserModel)
        {
            try
            {
                string accessToken      = Session["MicrosoftAccessToken"] as string;
                var    userGroupService = new UserGroupService(accessToken);
                var    userGroup        = await userGroupService.GetUserGroupById(userGroupId);

                await userGroupService.DeleteUserGroup(userGroup.Id);

                return(RedirectToAction("Index", new { groupId = userGroup.GroupId }));
            }
            catch
            {
                return(View());
            }
        }
示例#4
0
        // GET: GroupUser/Details/5
        public async Task <ActionResult> Details(string userGroupId)
        {
            string accessToken      = Session["MicrosoftAccessToken"] as string;
            var    roleTypeService  = new RoleTypeService(accessToken);
            var    userService      = new UserService(accessToken);
            var    userGroupService = new UserGroupService(accessToken);

            var allRoleTypes = await roleTypeService.GetAllRoleTypes();

            var userGroup = await userGroupService.GetUserGroupById(userGroupId);

            var user = await userService.GetUserById(userGroup.UserId);

            GroupUserModel guModel = new GroupUserModel();

            guModel.UserEmail   = user.Email;
            guModel.RoleTypeId  = userGroup.RoleTypeId;
            guModel.RoleName    = allRoleTypes.Single(r => r.Id == userGroup.RoleTypeId).RoleName;
            guModel.UserGroupId = userGroup.Id;

            ViewBag.GroupId = userGroup.GroupId;
            return(View(guModel));
        }