public HttpResponseMessage UpdateVanityUrl(VanityUrlDTO vanityUrl) { bool modified; // Clean Url var options = UrlRewriterUtils.GetOptionsFromSettings(new FriendlyUrlSettings(this.PortalSettings.PortalId)); var cleanUrl = FriendlyUrlController.CleanNameForUrl(vanityUrl.Url, options, out modified); if (modified) { return(this.Request.CreateResponse( HttpStatusCode.OK, new { Result = "warning", Title = Localization.GetString("CleanWarningTitle", Localization.SharedResourceFile), Message = Localization.GetString("ProfileUrlCleaned", Localization.SharedResourceFile), SuggestedUrl = cleanUrl, })); } // Validate for uniqueness var uniqueUrl = FriendlyUrlController.ValidateUrl(cleanUrl, -1, this.PortalSettings, out modified); if (modified) { return(this.Request.CreateResponse( HttpStatusCode.OK, new { Result = "warning", Title = Localization.GetString("DuplicateUrlWarningTitle", Localization.SharedResourceFile), Message = Localization.GetString("ProfileUrlNotUnique", Localization.SharedResourceFile), SuggestedUrl = uniqueUrl, })); } var user = this.PortalSettings.UserInfo; user.VanityUrl = uniqueUrl; UserController.UpdateUser(this.PortalSettings.PortalId, user); DataCache.RemoveCache(string.Format(CacheController.VanityUrlLookupKey, this.PortalSettings.PortalId)); // Url is clean and validated so we can update the User return(this.Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" })); }
public HttpResponseMessage UpdateVanityUrl(VanityUrlDTO vanityUrl) { bool modified; //Clean Url var options = UrlRewriterUtils.GetOptionsFromSettings(new FriendlyUrlSettings(PortalSettings.PortalId)); var cleanUrl = FriendlyUrlController.CleanNameForUrl(vanityUrl.Url, options, out modified); if (modified) { return Request.CreateResponse(HttpStatusCode.OK, new { Result = "warning", Title = Localization.GetString("CleanWarningTitle", Localization.SharedResourceFile), Message = Localization.GetString("ProfileUrlCleaned", Localization.SharedResourceFile), SuggestedUrl = cleanUrl }); } //Validate for uniqueness var uniqueUrl = FriendlyUrlController.ValidateUrl(cleanUrl, -1, PortalSettings, out modified); if (modified) { return Request.CreateResponse(HttpStatusCode.OK, new { Result = "warning", Title = Localization.GetString("DuplicateUrlWarningTitle", Localization.SharedResourceFile), Message = Localization.GetString("ProfileUrlNotUnique", Localization.SharedResourceFile), SuggestedUrl = uniqueUrl }); } var user = PortalSettings.UserInfo; user.VanityUrl = uniqueUrl; UserController.UpdateUser(PortalSettings.PortalId, user); DataCache.RemoveCache(string.Format(CacheController.VanityUrlLookupKey, PortalSettings.PortalId)); //Url is clean and validated so we can update the User return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" }); }