private static List <string> ValidateCustomLogo(AdvisorCobrandInfoViewModel options)
        {
            var errors = new List <string>();

            // only check for logo if it is a PL site, and some logo operation was performed
            if (options.PrivateLabelType.ToLowerInvariant() != "none" && options.LogoOperation.IsNotNullOrEmpty())
            {
                switch (options.LogoOperation.ToLowerInvariant())
                {
                case "missing":
                    errors.Add("A custom logo file must be uploaded");
                    break;

                case "personalization":
                    break;

                case "add":
                    // REFACTOR? assume that all rules regarding content (mime type, image sizes) are handled on the client
                    break;

                default:
                    break;
                }
            }
            return(errors);
        }
        public ActionResult SetAdvisorCobrandView(AdvisorCobrandInfoViewModel options)
        {
            var cobrandedSiteNameErrors = ValidateCobrandedSiteName(options);
            var cobrandedLogoErrors     = ValidateCustomLogo(options);
            var returnValue             = "";

            if (ModelState.IsValid && cobrandedSiteNameErrors.IsNullOrEmpty() && cobrandedLogoErrors.IsNullOrEmpty())
            {
                var savedOk = AdvisorCobrandAndSettingsManager.SaveCobrandedInfo(options.AdvisorCobrandInfo, FederatedLoginClient.User.UserMasterEntityId);
                return(new HttpStatusCodeResult(savedOk ? HttpStatusCode.OK : HttpStatusCode.InternalServerError));
            }
            // REVIEW: this is a non-standard way to handle validation errors. Ripe for refactoring as time permits.
            // We should set up validation attributes in the incoming model,
            // and rely upon Html.ValidationMessage's in the cshtml template, injecting error text into the markup.
            cobrandedSiteNameErrors.ForEach(error => ModelState["options.CobrandedSiteName"].Errors.Add(error));
            cobrandedLogoErrors.ForEach(error => ModelState["options.LogoData"].Errors.Add(error));

            // validation error -- round-trip the incoming model w/ the validation error list injected
            options.SavedStatus = returnValue;

            // need to refresh a few dictionaries which are not posted to this method, since they are critical to the UI
            var candidatesAndEditors = CobrandingManager.GetCandidatesAndEditors(options.AdvisorCompanyMeid, options.SelectedPrivateLabelEditorIds);

            options.PrivateLabelEditorCandidates = candidatesAndEditors.Item1;
            options.SelectedPrivateLabelEditors  = candidatesAndEditors.Item2;

            var view = PartialView(options.AdvisorSettingsPartial, options);

            Response.StatusCode = (int)HttpStatusCode.PartialContent;
            return(view);
        }
        public ActionResult GetAdvisorCobrandView(AdvisorCobrandInfoViewModel options)
        {
            var viewModel = new AdvisorCobrandInfoViewModel
            {
                //AdvisorCobrandInfo = Advisor.CobrandedAdvisorSettingsGet(options.AdvisorCobrandInfo)
                AdvisorCobrandInfo = PrivateLabelManager.GetAdvisorCobrandInfo(options.AdvisorID, options.AdvisorCompanyMeid)
            };

            viewModel.LoadSecurity("advisors-index", viewModel);
            ActionResult view = PartialView(options.AdvisorSettingsPartial, viewModel);

            return(view);
        }
 private static List <string> ValidateCobrandedSiteName(AdvisorCobrandInfoViewModel options)
 {
     return(CobrandingManager.ValidateCobrandedSiteName(options.AdvisorID, options.CobrandedSiteName, options.PrivateLabelType, options.PrivateLabelUrlType));
 }