MRoleProfile populateProfile(MUIRoleProfile profile) { MRoleProfile mRetVal = new MRoleProfile(); mRetVal.Name = profile.Name; mRetVal.Description = profile.Description; mRetVal.Id = profile.Id; mRetVal.IsSystem = profile.IsSystem; mRetVal.IsSystemOnly = profile.IsSystemOnly; mRetVal.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id; return(mRetVal); }
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)); }