public IHttpActionResult Save(MUIRoleProfile profile) { if (profile == null) { throw new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!"); } string mRetVal = "false"; MRoleProfile mProfileToSave = new MRoleProfile(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditRoles", true)), AccountUtility.CurrentProfile()); Logger mLog = Logger.Instance(); if (HttpContext.Current.Items["EditId"] != null) { if (profile.Id == -1) { if (!mSecurityInfo.MayAdd) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add"); mLog.Error(mError); return(this.InternalServerError(mError)); } mProfileToSave.AddedBy = AccountUtility.CurrentProfile().Id; mProfileToSave.AddedDate = DateTime.Now; } else { if (!mSecurityInfo.MayAdd) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit"); mLog.Error(mError); return(this.InternalServerError(mError)); } if (profile.IsSystem) { mProfileToSave.IsSystem = true; } if (profile.IsSystemOnly) { mProfileToSave.IsSystemOnly = true; } mProfileToSave = RoleUtility.GetProfile(profile.Id); mProfileToSave.UpdatedBy = AccountUtility.CurrentProfile().Id; mProfileToSave.UpdatedDate = DateTime.Now; } } mProfileToSave = populateProfile(profile); RoleUtility.Save(mProfileToSave); return(Ok(mRetVal)); }
protected void Page_Load(object sender, EventArgs e) { MRoleProfile myProfile = new MRoleProfile(); MSecurityInfo accountSecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile()); txtEditID.Text = Request.QueryString[GWWebHelper.RoleDataKeyField].ToString(); //HttpContext.Current.Session.Remove(AppConstants.ROLE_DATA_KEY_FIELD); myProfile.Id = int.Parse(txtEditID.Text); HttpContext.Current.Session.Add("EditId", myProfile.Id); myProfile = RoleUtility.GetProfile(myProfile.Id); litRole.Text = myProfile.Name; myProfile.SecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString()); ctlMembers.DataSource = RoleUtility.GetAccountsNotInRole(myProfile).ToArray(Type.GetType("System.String")); ctlMembers.SelectedItems = (string[])RoleUtility.GetAccountsInRole(myProfile).ToArray(Type.GetType("System.String")); ctlMembers.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string mRoleSeqId = GWWebHelper.GetQueryValue(Request, "RoleSeqID"); if (!String.IsNullOrEmpty(mRoleSeqId)) { int mRoleID = int.Parse(mRoleSeqId); if (mRoleID != -1) { m_Profile = RoleUtility.GetProfile(mRoleID); } else { m_Profile = new MRoleProfile(); } HttpContext.Current.Session.Add("EditId", m_Profile.Id); populatePage(); } }
public IHttpActionResult Delete([FromUri] int roleSeqId) { string mRetVal = "false"; MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditRoles", true)), AccountUtility.CurrentProfile()); if (!mSecurityInfo.MayDelete) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to delete"); Logger mLog = Logger.Instance(); mLog.Error(mError); return(this.InternalServerError(mError)); } else { if (HttpContext.Current.Items["EditId"] != null) { int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString()); if (mEditId == roleSeqId) { MRoleProfile mProfile = RoleUtility.GetProfile(roleSeqId); RoleUtility.DeleteRole(mProfile); } else { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); Logger mLog = Logger.Instance(); mLog.Error(mError); return(this.InternalServerError(mError)); } } else { Exception mError = new Exception("The identifier unknown and nothing has been saved!!!!"); Logger mLog = Logger.Instance(); mLog.Error(mError); return(this.InternalServerError(mError)); } } return(Ok(mRetVal)); }