public Core.Users.Domain.Customer GetCustomerData() { if (_customer == null || _customer.CustomerId != CustomerId) { ICustomerRepository customerRepository = new CustomerRepository(); _customer = customerRepository.GetCustomer(CustomerId); } if (_customer != null && _customer.Address != null) { if (!isStateFilled) { BindDropDown(); } BindShippingAddress(_customer.Address); } var hideFreeOnlineOption = false; if (_customer != null) { hideFreeOnlineOption = _customer.Email == null || string.IsNullOrEmpty(_customer.Email.ToString()); } if (ShowOnlineOption && EventType != EventType.Corporate && hideFreeOnlineOption) { ShowOnlineOption = false; } return(_customer); }
private void BindEventSearchDropdown(Core.Users.Domain.Customer customer) { if (string.IsNullOrEmpty(customer.Tag) && !CustomerHasMammoTest) { EventSearchTypeDropdownList.Items.Clear(); EventSearchTypeDropdownList.Visible = false; return; } var filterTypes = new List <OrderedPair <string, string> > { new OrderedPair <string, string>(EventSearchFilterType.All.ToString(), EventSearchFilterType.All.GetDescription()) }; var selectedValue = EventSearchFilterType.All.ToString(); if (!string.IsNullOrEmpty(customer.Tag)) { if (AccountByTag != null) { if (AccountByTag.IsHealthPlan) { filterTypes.Add(new OrderedPair <string, string>(EventSearchFilterType.HealthPlan.ToString(), EventSearchFilterType.HealthPlan.GetDescription())); selectedValue = EventSearchFilterType.HealthPlan.ToString(); } else { filterTypes.Add(new OrderedPair <string, string>(EventSearchFilterType.Corporate.ToString(), EventSearchFilterType.Corporate.GetDescription())); selectedValue = EventSearchFilterType.Corporate.ToString(); } } } //if (CustomerHasMammoTest) //{ // filterTypes.Add(new OrderedPair<string, string>(EventSearchFilterType.Mammo.ToString(), EventSearchFilterType.Mammo.GetDescription())); // selectedValue = EventSearchFilterType.Mammo.ToString(); //} EventSearchTypeDropdownList.Items.Clear(); EventSearchTypeDropdownList.DataSource = filterTypes; EventSearchTypeDropdownList.DataTextField = "SecondValue"; EventSearchTypeDropdownList.DataValueField = "FirstValue"; EventSearchTypeDropdownList.SelectedValue = selectedValue; EventSearchTypeDropdownList.DataBind(); }
public void PackageAndTestItems() { UpsellTest = true; //int forYear = 0; var currentSession = IoC.Resolve <ISessionContext>().UserSession; if (EventId > 0) { var eventRepository = IoC.Resolve <IEventRepository>(); var theEvent = eventRepository.GetById(EventId); if (theEvent != null) { EventType = theEvent.EventType; EventDateLabel.Text = theEvent.EventDate.ToString("dddd, MMMM dd, yyyy"); RegistrationMode = (short)theEvent.RegistrationMode; //forYear = theEvent.EventDate.Year; //var currentSession = IoC.Resolve<ISessionContext>().UserSession; var configurationSettingRepository = IoC.Resolve <IConfigurationSettingRepository>(); EnableAlaCarte = Convert.ToBoolean( configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.EnableAlaCarte)); if (EnableAlaCarte) { if (currentSession != null && currentSession.CurrentOrganizationRole.CheckRole((long)Roles.Customer)) { EnableAlaCarte = theEvent.EnableAlaCarteOnline; } else if (currentSession != null && currentSession.CurrentOrganizationRole.CheckRole((long)Roles.CallCenterRep) || currentSession != null && currentSession.CurrentOrganizationRole.CheckRole((long)Roles.CallCenterManager)) { EnableAlaCarte = theEvent.EnableAlaCarteCallCenter; } else if (currentSession != null && (currentSession.CurrentOrganizationRole.CheckRole((long)Roles.Technician) || currentSession.CurrentOrganizationRole.CheckRole((long)Roles.NursePractitioner))) { EnableAlaCarte = theEvent.EnableAlaCarteTechnician; } else if ( !(theEvent.EnableAlaCarteOnline || theEvent.EnableAlaCarteCallCenter || theEvent.EnableAlaCarteTechnician)) { EnableAlaCarte = false; } } var hostRepository = IoC.Resolve <IHostRepository>(); var host = hostRepository.GetHostForEvent(theEvent.Id); if (host != null) { EventNameLabel.Text = HttpUtility.HtmlEncode(host.OrganizationName); EventAddressLabel.Text = System.Web.Security.AntiXss.AntiXssEncoder.HtmlEncode(CommonCode.AddressMultiLine(host.Address.StreetAddressLine1, host.Address.StreetAddressLine2, host.Address.City, host.Address.State, host.Address.ZipCode.Zip), true); } var hospitalPartnerRepository = IoC.Resolve <IHospitalPartnerRepository>(); var hospitalPartnerId = hospitalPartnerRepository.GetHospitalPartnerIdForEvent(EventId); if (hospitalPartnerId > 0) { var organizationRepository = IoC.Resolve <IOrganizationRepository>(); var hospitalPartner = organizationRepository.GetOrganizationbyId(hospitalPartnerId); HospitalPartnerLabel.Text = hospitalPartner.Name; SponsoredInfoDiv.Visible = true; } } } var customerRepository = IoC.Resolve <ICustomerRepository>(); var userSession = IoC.Resolve <ISessionContext>().UserSession; Core.Users.Domain.Customer customer = null; if (CustomerId > 0) { customer = customerRepository.GetCustomer(CustomerId); } else if (userSession != null && userSession.CurrentOrganizationRole.CheckRole((long)Roles.Customer)) { customer = customerRepository.GetCustomer(userSession.CurrentOrganizationRole.OrganizationRoleUserId); } else if (Request.QueryString["CustomerId"] != null) { customer = customerRepository.GetCustomer(Convert.ToInt64(Request.QueryString["CustomerId"])); } if (Request.QueryString["EventCustomerID"] != null) { var eventCustomerRepository = IoC.Resolve <IUniqueItemRepository <EventCustomer> >(); var eventCustomer = eventCustomerRepository.GetById(Convert.ToInt64(Request.QueryString["EventCustomerID"])); if (eventCustomer != null) { if (customer == null) { customer = customerRepository.GetCustomer(eventCustomer.CustomerId); } SingleTestOverride = eventCustomer.SingleTestOverride; } } CorporateAccount account = null; if (EventId > 0 && customer != null) { _customerId = customer.CustomerId; var corporateAccountRepository = IoC.Resolve <ICorporateAccountRepository>(); account = corporateAccountRepository.GetbyEventId(EventId); var preApprovedTestRepository = IoC.Resolve <IPreApprovedTestRepository>(); var preApprovedTests = preApprovedTestRepository.GetByCustomerId(customer.CustomerId); var preApprovedPackageRepository = IoC.Resolve <IPreApprovedPackageRepository>(); var preApprovedPackageId = preApprovedPackageRepository.CheckPreApprovedPackages(customer.CustomerId); //IEnumerable<RequiredTest> requiredTests = null; //var requiredTestIdList = new List<long>(); //if (forYear > 0) //{ // var requiredTestRepository = IoC.Resolve<IRequiredTestRepository>(); // requiredTests = requiredTestRepository.GetByRequiredTestByCustomerIdAndYear(customer.CustomerId, forYear); // requiredTestIdList = requiredTests != null ? requiredTests.Select(x => x.TestId).ToList() : null; // if (!requiredTests.IsNullOrEmpty()) // RequiredTestIds = string.Join(",", requiredTests.Select(x => x.TestId)); //} var eventPackageRepository = IoC.Resolve <IEventPackageRepository>(); var eventPackages = eventPackageRepository.GetPackagesForEventByRole(EventId, RoleId); var eventCustomerRepository = IoC.Resolve <IEventCustomerRepository>(); var eventCustomer = eventCustomerRepository.Get(EventId, customer.CustomerId); var eventTestRepository = IoC.Resolve <IEventTestRepository>(); var eventTests = eventTestRepository.GetTestsForEventByRole(EventId, RoleId); var preApprovedTestIds = new List <long>(); if (preApprovedPackageId > 0 && eventPackages != null && eventPackages.Any() && account != null && account.AllowPreQualifiedTestOnly) { var eventPackage = eventPackages.FirstOrDefault(x => x.PackageId == preApprovedPackageId); PreApprovedPackage = eventPackage != null; PreApprovedPackageId = eventPackage != null ? eventPackage.PackageId : 0; } if (account != null && account.DefaultSelectionBasePackage && PreApprovedPackageId == 0) { if (!eventPackages.IsNullOrEmpty()) { var lowestPricePackage = eventPackages.OrderBy(ep => ep.Price).First(); PreApprovedPackageId = lowestPricePackage.PackageId; } } var testIdsToAdd = new List <long>(); if (account != null && account.AllowPreQualifiedTestOnly && (preApprovedTests != null && preApprovedTests.Any())) { AllowPrequalifiedTestOnly = true; var eventTestIds = eventTests.Select(et => et.TestId).ToList(); preApprovedTestIds = preApprovedTests.Where(pat => eventTestIds.Contains(pat.TestId)).Select(pat => pat.TestId).ToList(); var eventPackage = eventPackages.FirstOrDefault(x => x.PackageId == preApprovedPackageId); var preApprovedPackageTestIds = eventPackage != null?eventPackage.Package.Tests.Select(x => x.Id) : new List <long>(); var testIdsForCustomerOrder = eventTests.Where(x => x.Test.IsDefaultSelectionForOrder).Select(x => x.TestId).ToList(); if (!testIdsForCustomerOrder.IsNullOrEmpty()) { testIdsToAdd = preApprovedTestIds.Where(x => !preApprovedPackageTestIds.Contains(x)).ToList(); testIdsToAdd.AddRange(testIdsForCustomerOrder); // PreApprovedIndependentTestIds = string.Join(",", testIdsToAdd); } else { testIdsToAdd = preApprovedTestIds.Where(x => !preApprovedPackageTestIds.Contains(x)).ToList(); //PreApprovedIndependentTestIds = string.Join(",", preApprovedTestIds.Where(x => !preApprovedPackageTestIds.Contains(x))); } /*PreApprovedIndependentTestIds = string.Join(",", preApprovedTestIds.Where(x => !preApprovedPackageTestIds.Contains(x)));*/ if (userSession.CurrentOrganizationRole.CheckRole((long)Roles.Technician) || userSession.CurrentOrganizationRole.CheckRole((long)Roles.NursePractitioner) || userSession.CurrentOrganizationRole.CheckRole((long)Roles.CallCenterRep) || userSession.CurrentOrganizationRole.CheckRole((long)Roles.FranchisorAdmin) || userSession.CurrentOrganizationRole.CheckRole((long)Roles.FranchiseeAdmin)) { AllowPrequalifiedTestOnly = !account.AllowTechnicianUpdatePreQualifiedTests; } if (account.AllowPreQualifiedTestOnly && (eventCustomer == null || !eventCustomer.AppointmentId.HasValue) && (RegistrationFlow == null || !RegistrationFlow.SingleTestOverride) && (RegistrationFlow == null || string.IsNullOrEmpty(RegistrationFlow.DisqualifiedTest))) { if (!preApprovedTestIds.IsNullOrEmpty()) { if (PackageId > 0) { TestIds.AddRange(preApprovedTestIds); TestIds = TestIds.Distinct().ToList(); } else { TestIds = preApprovedTestIds; } } } } if (!EnableAlaCarte) { AllowPrequalifiedTestOnly = true; } //if (account != null && (requiredTests != null && requiredTests.Any())) //{ // testIdsToAdd.AddRange(requiredTests.Select(x => x.TestId).ToList()); // //PreApprovedIndependentTestIds = string.Join(",", requiredTests.Select(x => x.TestId)); //} if (!testIdsToAdd.IsNullOrEmpty()) { testIdsToAdd = testIdsToAdd.Distinct().ToList(); PreApprovedIndependentTestIds = string.Join(",", testIdsToAdd); } PrequalifedTestIds = string.Join(",", preApprovedTestIds); if (eventCustomer == null || !eventCustomer.AppointmentId.HasValue) { var testForCustomerOrder = eventTests.Where(x => x.Test.IsDefaultSelectionForOrder).Select(x => x.TestId).ToList(); if (TestIds.IsNullOrEmpty()) { TestIds = testForCustomerOrder; } else { TestIds.AddRange(testForCustomerOrder); TestIds = TestIds.Distinct().ToList(); } } else { if (PreApprovedPackage && preApprovedPackageId > 0) { PreApprovedPackage = PackageId == preApprovedPackageId; } } if (!DisqualifiedTestIds.IsNullOrEmpty()) { if (!string.IsNullOrWhiteSpace(SelectedPackageTestIds)) { try { var packageTestIds = SelectedPackageTestIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(long.Parse); if (packageTestIds.Any(x => DisqualifiedTestIds.Contains(x))) { PackageId = 0; } } catch (Exception ex) { IoC.Resolve <ILogManager>().GetLogger("Logger").Error("Exception occurred while converting package Test"); IoC.Resolve <ILogManager>().GetLogger("Logger").Error("Exception Message: " + ex.Message); IoC.Resolve <ILogManager>().GetLogger("Logger").Error("stack trace: " + ex.StackTrace); } } if (!TestIds.IsNullOrEmpty()) { TestIds = TestIds.Where(x => !DisqualifiedTestIds.Contains(x)).ToList(); } } //if (!requiredTests.IsNullOrEmpty() && !requiredTestIdList.IsNullOrEmpty()) //{ // TestIds.AddRange(requiredTestIdList); // TestIds = TestIds.Distinct().ToList(); //} } if (customer == null || !customer.DateOfBirth.HasValue) { return; } if (account != null) { UpsellTest = account.UpsellTest; } var now = DateTime.Now; var birth = customer.DateOfBirth.Value; Age = now.Year - birth.Year - ((now.DayOfYear < birth.DayOfYear) ? 1 : 0); }
private long SaveCustomer() { var commonCode = new CommonCode(); if (CurrentCustomer == null) { CurrentCustomer = new Core.Users.Domain.Customer(); } CurrentCustomer.Name = new Name { FirstName = txtFName.Text, LastName = txtLName.Text, MiddleName = txtMName.Text }; CurrentCustomer.MobilePhoneNumber = new PhoneNumber { PhoneNumberType = PhoneNumberType.Mobile, Number = commonCode.FormatPhoneNumber(txtCPhone.Text) }; CurrentCustomer.HomePhoneNumber = new PhoneNumber { PhoneNumberType = PhoneNumberType.Home, Number = commonCode.FormatPhoneNumber(txtHPhone.Text) }; CurrentCustomer.OfficePhoneNumber = new PhoneNumber { PhoneNumberType = PhoneNumberType.Office, Number = commonCode.FormatPhoneNumber(txtOPhone.Text) }; CurrentCustomer.PhoneOfficeExtension = PhoneOfficeExtension.Text; if (!string.IsNullOrEmpty(txtEmail.Text)) { string[] emailSplitUp = txtEmail.Text.Split(new[] { '@' }); CurrentCustomer.Email = new Email { Address = emailSplitUp[0], DomainName = emailSplitUp[1] }; } else { CurrentCustomer.Email = null; } if (!string.IsNullOrEmpty(txtDOB.Text)) { CurrentCustomer.DateOfBirth = Convert.ToDateTime(txtDOB.Text); } if (CurrentCustomer.Address == null) { CurrentCustomer.Address = new Address(); } else { CurrentCustomer.Address = new Address(CurrentCustomer.Address.Id); } CurrentCustomer.Address.StreetAddressLine1 = txtAddress1.Text; CurrentCustomer.Address.StreetAddressLine2 = txtAddress2.Text; CurrentCustomer.Address.ZipCode = new ZipCode { Zip = txtZip.Text }; CurrentCustomer.Address.Country = ddlCountry.SelectedItem.Text; CurrentCustomer.Address.State = hfstate.Value; CurrentCustomer.Address.City = txtCity.Text; if (CurrentCustomer.UserLogin == null) { CurrentCustomer.UserLogin = new UserLogin { UserName = txtUserName.Text, Password = txtPassword.Text, HintQuestion = ddlQues1.SelectedItem.Text, HintAnswer = txtAnswer.Text, IsSecurityQuestionVerified = false, UserVerified = false } } ; else { CurrentCustomer.UserLogin.UserName = txtUserName.Text; if (!string.IsNullOrEmpty(txtPassword.Text)) { CurrentCustomer.UserLogin.Password = txtPassword.Text; CurrentCustomer.UserLogin.Salt = null; } CurrentCustomer.UserLogin.HintQuestion = string.IsNullOrEmpty(CurrentCustomer.UserLogin.HintQuestion) ? ddlQues1.SelectedItem.Text : CurrentCustomer.UserLogin.HintQuestion; CurrentCustomer.UserLogin.HintAnswer = string.IsNullOrEmpty(CurrentCustomer.UserLogin.HintAnswer) ? txtAnswer.Text : CurrentCustomer.UserLogin.HintAnswer; } if (!string.IsNullOrEmpty(txtEmail2.Text)) { string[] emailSplitUp = txtEmail2.Text.Split(new[] { '@' }); CurrentCustomer.AlternateEmail = new Email { Address = emailSplitUp[0], DomainName = emailSplitUp[1] }; } else { CurrentCustomer.AlternateEmail = null; } if (rbtnGender.SelectedValue == Gender.Male.ToString() || rbtnGender.SelectedValue == Gender.Female.ToString()) { CurrentCustomer.Gender = rbtnGender.SelectedValue == Gender.Male.ToString() ? Gender.Male : Gender.Female; } if (CustomerType == CustomerType.New) { CurrentCustomer.MarketingSource = Request.Form[MarketingSourceDropDown.UniqueID + "_hidden"] ?? string.Empty; CurrentCustomer.AddedByRoleId = Convert.ToInt64(Roles.Technician); } else if (CustomerId <= 0) { CurrentCustomer.MarketingSource = Request.Form[MarketingSourceDropDown.UniqueID + "_hidden"] ?? string.Empty; CurrentCustomer.AddedByRoleId = Convert.ToInt64(Roles.Technician); } RegistrationFlow.MarketingSource = Request.Form[MarketingSourceDropDown.UniqueID + "_hidden"] ?? string.Empty; if (Convert.ToInt64(ddlFeet.SelectedValue) > 0 || Convert.ToInt64(ddlInch.SelectedValue) > 0) { CurrentCustomer.Height = new Height(Convert.ToInt64(ddlFeet.SelectedValue), Convert.ToInt64(ddlInch.SelectedValue)); } double weight; if (txtweight.Text.Trim().Length > 0 && Double.TryParse(txtweight.Text.Trim(), out weight)) { CurrentCustomer.Weight = new Weight(weight); } if (ddlrace.SelectedItem.Text != "Select Race") { CurrentCustomer.Race = (Race)Enum.Parse(typeof(Race), ddlrace.SelectedValue); } CurrentCustomer.InsuranceId = InsuranceIdTextbox.Text.Trim(); var prefferedLanguage = PreferredLanguageDropDown.SelectedItem.Text; var currentSession = IoC.Resolve <ISessionContext>().UserSession; if (!string.IsNullOrEmpty(prefferedLanguage)) { var languageRepository = IoC.Resolve <ILanguageRepository>(); var languageService = IoC.Resolve <ILanguageService>(); var language = languageRepository.GetByName(prefferedLanguage) ?? languageService.AddLanguage(prefferedLanguage, currentSession.CurrentOrganizationRole.OrganizationRoleUserId); CurrentCustomer.LanguageId = language.Id; } else { CurrentCustomer.LanguageId = null; } CurrentCustomer.PreferredLanguage = PreferredLanguageDropDown.SelectedItem.Text; CurrentCustomer.BestTimeToCall = Convert.ToInt64(BestTimeToCallDropdown.SelectedValue); CurrentCustomer.Ssn = SsnTextbox.Text.Replace("-", "").Trim(); CurrentCustomer.Hicn = MedicareIdTextbox.Text.Trim(); CurrentCustomer.Mbi = MBINumberTextbox.Text.Trim(); CurrentCustomer.MedicareAdvantageNumber = MedicareAdvantageNumber.Text.Trim(); CurrentCustomer.MedicareAdvantagePlanName = MedicareAdvantagePlanName.Text.Trim(); CurrentCustomer.EnableTexting = rbtnEnableTexting.SelectedValue == "true"; CurrentCustomer.EnableVoiceMail = rbtnEnableVoiceMail.SelectedValue == "true"; CurrentCustomer.EnableEmail = rbtnEnableEmail.SelectedValue == "true"; CurrentCustomer.PreferredContactType = ddlPreferredContactType.SelectedIndex > 0 ? (long?)long.Parse(ddlPreferredContactType.SelectedValue) : null; CurrentCustomer.PhoneHomeConsentId = long.Parse(ddlPatientConsentPrimary.SelectedValue); CurrentCustomer.PhoneCellConsentId = long.Parse(ddlPatientConsentCell.SelectedValue); CurrentCustomer.PhoneOfficeConsentId = long.Parse(ddlPatientConsentOffice.SelectedValue); var customerService = IoC.Resolve <ICustomerService>(); customerService.SaveCustomer(CurrentCustomer, currentSession.CurrentOrganizationRole.OrganizationRoleUserId); LogAudit(ModelType.Edit, CurrentCustomer, CustomerId); return(CurrentCustomer.CustomerId); }