public IHttpActionResult SaveMembers(UIAccounts groupAccounts) { string mRetVal = "false"; Logger mLog = Logger.Instance(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile()); if (!mSecurityInfo.MayEdit) { 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)); } if (HttpContext.Current.Items["EditId"] == null || HttpContext.Current.Items["EditId"].ToString().ToLowerInvariant() != groupAccounts.SeqId.ToString().ToLowerInvariant()) { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } MAccountProfile accountProfile = AccountUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(accountProfile.Account); MGroupRoles mProfile = new MGroupRoles(); mProfile.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id; mProfile.GroupSeqId = groupAccounts.SeqId; mProfile.Roles = String.Join(",", groupAccounts.Accounts); mProfile.AddedUpdatedBy = accountProfile.Id; GroupUtility.UpdateGroupRoles(mProfile); return(Ok(mRetVal)); }
/// <summary> /// Gets the selected roles. /// </summary> /// <param name="profile">The profile.</param> /// <returns>System.String[][].</returns> public string[] GetSelectedRoles(MGroupRoles profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!!"); } ArrayList ClientRoles = new ArrayList(); m_DGroups.GroupRolesProfile = profile; DataTable myDataTable = null; if (DatabaseIsOnline()) { try { myDataTable = m_DGroups.GroupRoles(); DataRow myDR = null; foreach (DataRow myDR_loopVariable in myDataTable.Rows) { myDR = myDR_loopVariable; ClientRoles.Add(myDR["Role"].ToString()); } } catch (DataAccessLayerException) { throw; } } return((string[])ClientRoles.ToArray(typeof(string))); }
/// <summary> /// Updates the group roles. /// </summary> /// <param name="profile">The profile.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> public bool UpdateGroupRoles(MGroupRoles profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!!"); } bool mRetVal = false; m_DGroups.GroupRolesProfile = profile; if (DatabaseIsOnline()) { mRetVal = m_DGroups.UpdateGroupRoles(); } return(mRetVal); }
protected void Page_Load(object sender, EventArgs e) { MAccountProfile updatingAccount = null; MGroupProfile mGroupProfile = GroupUtility.GetProfile(int.Parse(HttpContext.Current.Request["GroupSeqId"])); txtEditID.Text = mGroupProfile.Id.ToString(); litGroup.Text = mGroupProfile.Name; HttpContext.Current.Session.Add("EditId", mGroupProfile.Id); updatingAccount = AccountUtility.CurrentProfile(); DataView myDataView = RoleUtility.GetAllRolesBySecurityEntity(int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString())).DefaultView; if (!updatingAccount.IsSystemAdmin) { String rowFilter = "IS_SYSTEM <> 1 AND IS_SYSTEM_ONLY <> 1"; myDataView.RowFilter = rowFilter; } try { MGroupProfile myGroupProfile = new MGroupProfile(); myGroupProfile = GroupUtility.GetProfile(int.Parse(txtEditID.Text.ToString())); litGroup.Text = myGroupProfile.Name; MGroupRoles mProfile = new MGroupRoles(); mProfile.SecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString()); mProfile.GroupSeqId = int.Parse(txtEditID.Text.ToString()); ctlMembers.SelectedItems = GroupUtility.GetSelectedRoles(mProfile); } catch (Exception ex) { Logger log = Logger.Instance(); log.Debug(ex); } ctlMembers.DataSource = myDataView; ctlMembers.DataField = "Name"; ctlMembers.DataBind(); }