public static ActionResult UpdateProfileProperty(UpdateProfilePropertyRequest request) { ActionResult actionResult = new ActionResult(); try { int pid = request.PortalId ?? PortalSettings.Current.PortalId; if (!PortalSettings.Current.UserInfo.IsSuperUser && PortalSettings.Current.PortalId != pid) { actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage); } if (actionResult.IsSuccess) { int definitionId = request.PropertyDefinitionId ?? Null.NullInteger; if (definitionId != Null.NullInteger) { dynamic profileProperty = GetProfileProperty(request.PropertyDefinitionId, pid).Data.ProfileProperty; request.PropertyName = profileProperty.PropertyName; ProfilePropertyDefinition property = new ProfilePropertyDefinition(pid) { PropertyDefinitionId = definitionId, DataType = request.DataType, DefaultValue = request.DefaultValue, PropertyCategory = request.PropertyCategory, PropertyName = request.PropertyName, ReadOnly = request.ReadOnly, Required = request.Required, ValidationExpression = request.ValidationExpression, ViewOrder = request.ViewOrder, Visible = request.Visible, Length = request.Length, DefaultVisibility = (UserVisibilityMode)request.DefaultVisibility }; actionResult = ValidateProperty(property); if (actionResult.IsSuccess) { ProfileController.UpdatePropertyDefinition(property); DataCache.ClearDefinitionsCache(pid); actionResult.Data = new { MemberProfile = GetProfileProperties(pid).Data.Properties, PropertyLocalization = GetProfilePropertyLocalization(PortalSettings.Current.CultureCode, property.PropertyName, property.PropertyCategory).Data, GetListInfo(property.PropertyName, PortalSettings.Current.PortalId).Data.Entries }; actionResult.Message = DNNLocalization.Localization.GetString("MemberProfileUpdated", Components.Constants.LocalResourcesFile); } } } else { actionResult.AddError(HttpStatusCode.BadRequest.ToString(), ""); } } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }
public static ActionResult AddProfileProperty(UpdateProfilePropertyRequest request) { ActionResult actionResult = new ActionResult(); try { int pid = request.PortalId ?? PortalSettings.Current.PortalId; if (!PortalSettings.Current.UserInfo.IsSuperUser && PortalSettings.Current.PortalId != pid) { actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage); } if (actionResult.IsSuccess) { ProfilePropertyDefinition property = new ProfilePropertyDefinition(pid) { DataType = request.DataType, DefaultValue = request.DefaultValue, PropertyCategory = request.PropertyCategory, PropertyName = request.PropertyName, ReadOnly = request.ReadOnly, Required = !Globals.IsHostTab(PortalSettings.Current.ActiveTab.TabID) && request.Required, ValidationExpression = request.ValidationExpression, ViewOrder = request.ViewOrder, Visible = request.Visible, Length = request.Length, DefaultVisibility = (UserVisibilityMode)request.DefaultVisibility }; actionResult = ValidateProperty(property); if (actionResult.IsSuccess) { int propertyId = ProfileController.AddPropertyDefinition(property); if (propertyId < Null.NullInteger) { actionResult.AddError(HttpStatusCode.BadRequest.ToString(), string.Format(DNNLocalization.Localization.GetString("DuplicateName", PersonaBar.Constants.LocalResourcesFile))); } else { DataCache.ClearDefinitionsCache(pid); actionResult.Data = new { MemberProfile = GetProfileProperties(pid).Data.Properties, PropertyLocalization = GetProfilePropertyLocalization(PortalSettings.Current.CultureCode, property.PropertyName, property.PropertyCategory).Data }; actionResult.Message = DNNLocalization.Localization.GetString("MemberProfileAdded", Components.Constants.LocalResourcesFile); } } } } catch (Exception exc) { actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message); } return(actionResult); }
/// ----------------------------------------------------------------------------- /// <summary> /// Clears the Profile Definitions Cache /// </summary> /// <param name="portalId">Id of the Portal</param> /// ----------------------------------------------------------------------------- public static void ClearProfileDefinitionCache(int portalId) { DataCache.ClearDefinitionsCache(GetEffectivePortalId(portalId)); }
public static void ClearProfileDefinitionCache(int PortalId) { DataCache.ClearDefinitionsCache(PortalId); }