Example #1
0
        public ActionResult DeleteProfileProperty(int propertyId)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int pid = PortalSettings.PortalId;
                if (!UserInfo.IsSuperUser && PortalSettings.PortalId != pid)
                {
                    actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                }

                if (actionResult.IsSuccess)
                {
                    ProfilePropertyDefinition propertyDefinition = ProfileController.GetPropertyDefinition(propertyId, pid);

                    if (!CanDeleteProperty(propertyDefinition))
                    {
                        actionResult.AddError(HttpStatusCode.BadRequest.ToString(), "ForbiddenDelete");
                    }
                    if (actionResult.IsSuccess)
                    {
                        ProfileController.DeletePropertyDefinition(propertyDefinition);
                        DataCache.ClearDefinitionsCache(pid);
                        actionResult.Data = new { MemberProfile = Managers.MemberProfileManager.GetProfileProperties(pid).Data.Properties };
                    }
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
Example #2
0
        public ActionResult UpdateProfilePropertyOrders(UpdateProfilePropertyOrdersRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                if (request != null)
                {
                    int pid = request.PortalId ?? PortalSettings.PortalId;
                    if (!UserInfo.IsSuperUser && PortalSettings.PortalId != pid)
                    {
                        actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                    }

                    if (actionResult.IsSuccess)
                    {
                        for (int i = 0; i <= request.Properties.Length - 1; i++)
                        {
                            var    profileProperty = ProfileController.GetPropertyDefinition(request.Properties[i].PropertyDefinitionId.Value, pid);
                            string ControlType     = Managers.MemberProfileManager.GetControlType(profileProperty.DataType);
                            if (profileProperty.PropertyValue == "-1" && (ControlType == "Country" || ControlType == "Region" || ControlType == "List"))
                            {
                                profileProperty.PropertyValue = "";
                            }
                            if (profileProperty.ViewOrder != request.Properties[i].ViewOrder)
                            {
                                profileProperty.ViewOrder = request.Properties[i].ViewOrder;
                                ProfileController.UpdatePropertyDefinition(profileProperty);
                            }
                        }
                        DataCache.ClearDefinitionsCache(pid);
                    }
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }