// 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")); } }
/// <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; }
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()); } }
// 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)); }