private static UpdateProfilePropertyRequest MapProfileProperty(dynamic profileProperty) { UpdateProfilePropertyRequest updateProfilePropertyRequest = new UpdateProfilePropertyRequest(); if (profileProperty != null) { updateProfilePropertyRequest.PortalId = profileProperty.PortalId; updateProfilePropertyRequest.PropertyDefinitionId = profileProperty.PropertyDefinitionId; updateProfilePropertyRequest.PropertyName = profileProperty.PropertyName; updateProfilePropertyRequest.DataType = IsExistsDataType(profileProperty.DataType) ? profileProperty.DataType : 0; updateProfilePropertyRequest.PropertyCategory = profileProperty.PropertyCategory; updateProfilePropertyRequest.Length = profileProperty.Length; updateProfilePropertyRequest.DefaultValue = profileProperty.DefaultValue; updateProfilePropertyRequest.ValidationExpression = profileProperty.ValidationExpression; updateProfilePropertyRequest.Required = profileProperty.Required; updateProfilePropertyRequest.ReadOnly = profileProperty.ReadOnly; updateProfilePropertyRequest.Visible = profileProperty.Visible; updateProfilePropertyRequest.ViewOrder = profileProperty.ViewOrder; updateProfilePropertyRequest.DefaultVisibility = (int)profileProperty.DefaultVisibility; } else { updateProfilePropertyRequest.DefaultVisibility = (int)UserVisibilityMode.AdminOnly; updateProfilePropertyRequest.Visible = true; } return(updateProfilePropertyRequest); }
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); }
public ActionResult AddUpdateMemberProfile(UpdateProfilePropertyRequest request) { ActionResult actionResult = new ActionResult(); if (request != null) { if (request.PropertyDefinitionId > 0) { actionResult = Managers.MemberProfileManager.UpdateProfileProperty(request); } else { actionResult = Managers.MemberProfileManager.AddProfileProperty(request); } } return(actionResult); }