private bool CheckUserApproverPrivilege() { var portalUserId = int.Parse(new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name).ToString(CultureInfo.InvariantCulture)); var delegateService = new ApprovalDelegateService(); if (!delegateService.CheckDelegate(portalUserId)) { Response.Redirect("XpenseManager.aspx?tabParentId=1&tabId=35&tabtype=1&tabOrder=1"); return(false); } return(true); }
protected void DgPortalUsersItemCommand(object source, DataGridCommandEventArgs e) { dgPortalUsers.SelectedIndex = e.Item.ItemIndex; var id = (DataCheck.IsNumeric(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString()) : 0; if (id < 1) { ConfirmAlertBox1.ShowMessage("Invalid Record Selection!", ConfirmAlertBox.PopupMessageType.Error); return; } var portalUser = new PortalServiceManager().GetPortalUserById(id); if (portalUser == null || portalUser.PortalUserId < 1) { ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error); return; } var user = Membership.GetUser(portalUser.UserId); if (user == null) { ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error); return; } var status = (portalUser.Status) ? 1 : 0; var email = user.Email; var delegateService = new ApprovalDelegateService(); if (!delegateService.AddDelegateApprover(portalUser.PortalUserId, status, email)) { ConfirmAlertBox1.ShowMessage("User could not be added as an Approver. Please try again later or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error); return; } ConfirmAlertBox1.ShowSuccessAlert("User was successfully assigned the Approver role."); }