public ActionResult AddAdvisorId(AdvisorInformationViewModel model)
        {
            model.ListAdvisorIds = model.ListAdvisorIds ?? new List <AdvisorIdClass>();
            var isValid = AdvisorViewManager.ValidateAdvisorIds(model as AdvisorInformationViewModel, ModelState);

            if (isValid)
            {
                model.ListAdvisorIds.Add(new AdvisorIdClass {
                    Status = ProfileItemStatus.Insert
                });
            }

            return(PartialView("EditorTemplates/Admin.AdvisorInformation", model));
        }
        public ActionResult AdminInformationUpdate(AdvisorInformationViewModel viewModel)
        {
            viewModel.LoadSecurity("advisors-admininformationupdate", viewModel);

            // no validation on DBA if not IC
            var editIdType = viewModel.CanView(SecurityConstants.Advisor.EditAdvisorIdType);

            if (viewModel.AdvisorType.TypeId != AdvisorInfoManager.IndependentContractorTypeId && ModelState.ContainsKey("AdvisorDoingBusinessAs"))
            {
                ModelState["AdvisorDoingBusinessAs"].Errors.Clear();
            }

            // no validate on Type for self-edit
            if (!editIdType && ModelState.ContainsKey("AdvisorType.TypeId"))
            {
                ModelState["AdvisorType.TypeId"].Errors.Clear();
            }

            // no validate AdvisorID for self-edit
            if (!editIdType && viewModel.ListAdvisorIds.IsNotNullOrEmpty())
            {
                for (int i = 0; i < viewModel.ListAdvisorIds.Count; i++)
                {
                    var name = string.Format("ListAdvisorIds[{0}].Id", i);
                    if (ModelState.ContainsKey(name))
                    {
                        ModelState[name].Errors.Clear();
                    }
                }
            }

            if (ModelState.ContainsKey("SellingTravelSince"))
            {
                ModelState["SellingTravelSince"].Errors.Clear();
            }

            if (ModelState.ContainsKey("Badge.Company"))
            {
                ModelState["Badge.Company"].Errors.Clear();
            }
            if (ModelState.ContainsKey("Badge.Name"))
            {
                ModelState["Badge.Name"].Errors.Clear();
            }
            if (ModelState.ContainsKey("Badge.NickName"))
            {
                ModelState["Badge.NickName"].Errors.Clear();
            }
            if (ModelState.ContainsKey("Badge.Location"))
            {
                ModelState["Badge.Location"].Errors.Clear();
            }

            var isValid = ModelState.IsValid && AdvisorViewManager.ValidateAdvisorIds(viewModel, ModelState);

            if (isValid)
            {
                var userMasterEntityId = FederatedLoginClient.User.UserMasterEntityId;
                var success            = AdvisorInfoManager.SaveAdminInfo(userMasterEntityId, viewModel.AdvisorInformation, editIdType);
                return(new HttpStatusCodeResult(success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError));
            }
            else
            {
                // Validation error(s) detected on the server side
                var partialView = PartialView("EditorTemplates/Admin.AdvisorInformation", viewModel);
                Response.StatusCode = (int)HttpStatusCode.PartialContent;
                return(partialView);
            }
        }