public ActionResult AdminSpecialtiesUpdate(AdvisorTravelSpecialtiesViewModel viewModel) { viewModel.LoadSecurity("advisors-adminspecialtiesupdate", viewModel); viewModel.AdvisorTravelSpecialties.LoadSecurity("advisors-adminspecialtiesupdate", viewModel.AdvisorTravelSpecialties); // TODO: wire the security object into this controller end-point, currently only in advisors-index, justin help // if (viewModel.CanView(SecurityConstants.Advisor.EditAdmin)) { if (ModelState.IsValid) { AdvisorInfoManager.SetInterestList(viewModel.AdvisorTravelSpecialties); AdvisorInfoManager.SetDestinationList(viewModel.AdvisorTravelSpecialties); var userMasterEntityId = FederatedLoginClient.User.UserMasterEntityId; var success = AdvisorInfoManager.SaveTravelSpecialties(userMasterEntityId, viewModel.AdvisorTravelSpecialties); return(new HttpStatusCodeResult(success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError)); } else { // Validation error(s) detected on the server side var partialView = PartialView("EditorTemplates/Admin.TravelSpecialties", viewModel); Response.StatusCode = (int)HttpStatusCode.PartialContent; return(partialView); } } }
public static AdvisorHotelBooking GetParentAgencyHotelBookingInfo(int advisorId) { var hotelBookingInfo = AdvisorInfoManager.GetHotelBookingInfoForParentAgency(advisorId); if (hotelBookingInfo != null) { return new AdvisorHotelBooking { BookingPrefatoryCode = hotelBookingInfo.BookingPrefatoryCode, BookingPseudoCityCode = hotelBookingInfo.BookingPseudoCityCode, BookingQueueNumber = hotelBookingInfo.BookingQueueNumber, AdvisorMasterEntityId = advisorId, SameAsAgency = true } } ; return(null); }
public ActionResult AdminEventBadgeUpdate(AdvisorInformationViewModel viewModel) { if (viewModel.Badge == null || !viewModel.Badge.DirtyFlag) //if nothing has changed don't need to go any further { return(new HttpStatusCodeResult(HttpStatusCode.OK)); } viewModel.LoadSecurity("advisors-admininformationupdate", viewModel); //ignore errors for non-badge related fields tcchc.ValidationHelper.IgnoreValidationExceptFor(ModelState, "Badge.Company", "Badge.Name", "Badge.NickName", "Badge.Location"); if (ModelState.IsValid) { var success = AdvisorInfoManager.SaveEventBadgeInfo(FederatedLoginClient.User.UserMasterEntityId, viewModel.AdvisorInformation); return(new HttpStatusCodeResult(success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError)); } else { // Validation error(s) detected on the server side var partialView = PartialView("EditorTemplates/Admin.EventBadge", viewModel); Response.StatusCode = (int)HttpStatusCode.PartialContent; return(partialView); } }
public AdvisorDetailViewModel GetAdvisorDetailViewModel(int advisorId, bool isEdit) { var manager = new AdvisorManager(); var detailInfo = manager.GetProductDetailInfo(advisorId); if (detailInfo == null) { return(null); } detailInfo.IsEditable = AdvisorIsEditable(detailInfo.AdvisorMasterEntityId, detailInfo.AdvisorCompanyMasterEntityId, detailInfo.AdvisorCompanyParentMasterEntityId); detailInfo.IsPreview = false; detailInfo.AdvisorStatus = TypeChanger.DoEnum(detailInfo.Status, ProfileStatus.Unknown); detailInfo.Certifications = AdvisorInfoManager.GetAdvisorCertifications(detailInfo.AdvisorCertificationsXml); detailInfo.VisitedPlaces = AdvisorInfoManager.GetVisitedPlaces(detailInfo.AdvisorPlacesVisitedXml); detailInfo.Interests = BaseDetailInfoHelpers.GetTravelElements(detailInfo.AdvisorInterestTypesXml); detailInfo.SpecialtyDestinations = BaseDetailInfoHelpers.GetTravelElements(detailInfo.AdvisorSpecialtyCountriesXml); detailInfo.Languages = BaseDetailInfoHelpers.GetTravelElements(detailInfo.AdvisorLanguagesXml); detailInfo.AlliancePrograms = BaseDetailInfoHelpers.GetTravelElements(detailInfo.AdvisorAllianceProgramsXml); detailInfo.ConditionalLeadsName = AdvisorInfoManager.GetConditionalLeadsName(detailInfo.AlliancePrograms); detailInfo.AdvisorPrimarydAddress = ProfileContactInfoManagerBase.GetPrimaryAddress(detailInfo.ProfileAddressXml); ProfileAddressManager.DisambiguateAddressCity(detailInfo.AdvisorPrimarydAddress, isEdit); if (HttpContext.Current.Request.QueryString["consumer"] == "1") { detailInfo.IsEditable = false; detailInfo.IsPreview = true; } var user = FederatedLoginClient.User; var viewModel = new AdvisorDetailViewModel { AdvisorMasterEntityId = detailInfo.AdvisorMasterEntityId, Status = detailInfo.AdvisorStatus, AdvisorName = string.Format("{0} {1}", detailInfo.AdvisorFirstName, detailInfo.AdvisorLastName) }; viewModel.ShowReviewsTab = ReviewHelper.ShowReview(detailInfo.TotalCompletedReviews, detailInfo.TotalBlockedReviews, detailInfo.TotalActiveReviews); if (viewModel.ShowReviewsTab) { viewModel.ReviewsInfoJson = new RatingAndReviewManager().GetReviewsInfoJsonForAdvisor(detailInfo); } viewModel.HeaderInfoPlus = new AdvisorHeaderInfoPlus { Header = new AdvisorHeaderInfoViewModel { AdvisorHeaderInfo = AdvisorInfoManager.BuildHeaderInfo(detailInfo) }, ContactAdvisor = GetContactAdvisor(detailInfo), ReviewBadge = ReviewHelper.BuildBadgeModelForAdvisorDetailPage(detailInfo) }; viewModel.AboutMePlus = new AdvisorAboutMePlus { Alliances = AdvisorInfoManager.BuildAboutMe(detailInfo), Overview = GetProfileOverviewInfo(detailInfo), IsActive = detailInfo.AdvisorIsActive, CompanyIsActive = detailInfo.AdvisorCompanyIsActive, AdvisorMasterEntityId = advisorId }; if (user.IsComposerUser) { AddCommunityInfoForAdvisor(viewModel.AboutMePlus); } viewModel.DetailInfo = detailInfo; viewModel.ContactInfo = AdvisorContactInfoManager.BuildContactInfo(detailInfo); viewModel.CobrandInfo = new AdvisorCobrandInfoViewModel { AdvisorCobrandInfo = AdvisorCobrandAndSettingsManager.BuildCobrandInfo(detailInfo) }; ProfileAddressManager.DisambiguateAddressCity(viewModel.ContactInfo.PrimaryAddress, isEdit); ProfileAddressManager.DisambiguateAddressCities(viewModel.ContactInfo.Addresses, isEdit); // note that if an advisor is using the agency default personalization, the advisor personalized address will be null var personalizedAddress = TouchPoints.Framework.Utilities.Xml.Deserialize <PersonalizationAddress>(detailInfo.AdvisorPersonalizedAddressXml) ?? new PersonalizationAddress(); detailInfo.AdvisorPersonalizedAddress = personalizedAddress; viewModel.AdvisorPersonalization = new AdvisorPersonalizationInfo { AdvisorName = detailInfo.AdvisorPersonalizedName, AgencyName = detailInfo.AgencyPersonalizedName, DoingBusinessAs = detailInfo.AdvisorPersonalizedDoingBusinessAs, AddressLine1 = personalizedAddress.AddressLine1, AddressLine2 = personalizedAddress.AddressLine2, City = personalizedAddress.City, RegionNameEng = personalizedAddress.State, RegionId = personalizedAddress.RegionId, RegionCode = personalizedAddress.RegionCode, CountryNameEng = personalizedAddress.Country, CountryId = personalizedAddress.CountryId, PostalCode = personalizedAddress.PostalCode, Phone = detailInfo.AdvisorPersonalizedPrimaryPhone, SecondPhone = detailInfo.AdvisorPersonalizedSecondaryPhone, WebAddress = detailInfo.AdvisorPersonalizedWebsite, Email = detailInfo.AdvisorPersonalizedEmail, StateOfSellerId = detailInfo.AdvisorPersonalizedStateOfSellerId, LogoUrl = detailInfo.AdvisorCompanyLogo, AssociatedMasterEntityId = detailInfo.AdvisorMasterEntityId, AssociatedParentMasterEntityId = detailInfo.AdvisorCompanyParentMasterEntityId, UseAgencyDefaultPersonalization = detailInfo.UseAgencyDefaultPersonalization }; personalizedAddress = Xml.Deserialize <PersonalizationAddress>(detailInfo.AgencyPersonalizedAddressXml) ?? new PersonalizationAddress(); viewModel.AgencyPersonalization = new AgencyPersonalizationInfo { AgencyName = detailInfo.AgencyPersonalizedName, AddressLine1 = personalizedAddress.AddressLine1, AddressLine2 = personalizedAddress.AddressLine2, City = personalizedAddress.City, RegionNameEng = personalizedAddress.State, RegionId = personalizedAddress.RegionId, RegionCode = personalizedAddress.RegionCode, CountryNameEng = personalizedAddress.Country, CountryId = personalizedAddress.CountryId, PostalCode = personalizedAddress.PostalCode, Phone = detailInfo.AgencyPersonalizedPrimaryPhone, SecondPhone = detailInfo.AgencyPersonalizedSecondaryPhone, WebAddress = detailInfo.AgencyPersonalizedWebsite, Email = detailInfo.AgencyPersonalizedEmail, StateOfSellerId = detailInfo.AgencyPersonalizedStateOfSellerId, LogoUrl = detailInfo.LogoUrl, AssociatedMasterEntityId = detailInfo.AdvisorCompanyMasterEntityId, AssociatedParentMasterEntityId = detailInfo.AdvisorCompanyParentMasterEntityId, }; viewModel.Information = new AdvisorInformationViewModel { AdvisorInformation = AdvisorInfoManager.BuildAdminInfo(detailInfo) }; viewModel.Specialties = new AdvisorTravelSpecialtiesViewModel { AdvisorTravelSpecialties = AdvisorInfoManager.BuildTravelSpecialties(detailInfo) }; // fill in personalization IC status, since the value in DetailInfo may be unreliable viewModel.AdvisorPersonalization.IsIndependentContractor = (viewModel.Information.AdvisorType.TypeId == AdvisorInfoManager.IndependentContractorTypeId); // TODO: only need these for edit by certain people with permissions if (null != viewModel.Specialties) { viewModel.Specialties.SpecialtyCountriesLookup = SpecialtyDestinations.Get(null, ProfileType.Advisor); } viewModel.OutOfOffice = new AdvisorOutOfOffice(); viewModel.Settings = AdvisorCobrandAndSettingsManager.BuildAdvisorSettings(detailInfo); AgencyViewManager.CalculateFieldLevelPermissions(viewModel.Settings, user); viewModel.SupplierMarketingOptions = new SupplierMarketingOptionsViewManager().GetSupplierMarketingOptionsForMember(advisorId); viewModel.SupplierMarketingOptions.MemberHasOverrideRole = detailInfo.OverrideAgencySupplierMarketing; viewModel.SupplierMarketingOptions.AgencyMeid = detailInfo.AdvisorCompanyMasterEntityId; viewModel.ConsumerNotifications = new ConsumerNotificationsViewManager().GetNotificationsForAdvisor(advisorId, viewModel.Settings.Meid, viewModel.Settings.ParentMeid); viewModel.SecurityData = new AdvisorProfileSecurityData(); var securityModel = TouchPoints.Framework.Utilities.Xml.Deserialize <StaffSecurityModelXml>(detailInfo.ProfileRolesXml); viewModel.AdvisorSecurity = SecurityManager.BuildAdvisorSecurity(securityModel); viewModel.HotelBooking = new AdvisorHotelBookingViewModel(); viewModel.HotelBooking.HotelBooking = new AdvisorHotelBooking { AdvisorMasterEntityId = viewModel.AdvisorMasterEntityId, AgentId = detailInfo.AgentId, BookingPrefatoryCode = detailInfo.BookingPrefatoryCode, BookingPseudoCityCode = detailInfo.BookingPseudoCityCode, BookingQueueNumber = detailInfo.BookingQueueNumber, AgentInterfaceId = detailInfo.AgentInterfaceId, SameAsAgency = detailInfo.IsBookingSameAsAgency }; viewModel.AdvisorLogoExists = !String.IsNullOrEmpty(viewModel.AdvisorPersonalization.LogoUrl); viewModel.AgencyDefaultLogoExists = !String.IsNullOrEmpty(viewModel.AgencyPersonalization.LogoUrl); viewModel.PersonalizationGuidelinesUrl = Config.AppSettings.PersonalizationGuidelinesUrl; return(viewModel); }
public static bool SetHotelBookingInfo(AdvisorHotelBooking hotelBooking) { return(AdvisorInfoManager.SaveHotelBooking(FederatedLoginClient.User.UserMasterEntityId, hotelBooking)); }
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); } }