public OnlineSummaryModel GetOnlineSummaryModel(string guid)
        {
            var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid);
            var model = new OnlineSummaryModel {
                RequestValidationModel = onlineRequestValidationModel
            };

            if (onlineRequestValidationModel.RequestStatus == OnlineRequestStatus.InvalidOperation || onlineRequestValidationModel.RequestStatus == OnlineRequestStatus.InValid)
            {
                return(model);
            }

            var appliedSouceCode = _eventSchedulerService.GetSourceCodeApplied(onlineRequestValidationModel.TempCart);

            model.EventCustomerOrderSummaryModel = _eventSchedulerService.GetEventCustomerOrderSummaryModel(onlineRequestValidationModel.TempCart, appliedSouceCode);

            return(model);
        }
Beispiel #2
0
        public OnlineSchedulingCustomerInfoEditModel GetPaymentInfo(string guid)
        {
            var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid);

            if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid)
            {
                return new OnlineSchedulingCustomerInfoEditModel
                       {
                           RequestValidationModel = onlineRequestValidationModel
                       }
            }
            ;

            var tempCart = onlineRequestValidationModel.TempCart;
            var model    = new OnlineSchedulingCustomerInfoEditModel
            {
                ProcessAndCartViewModel        = _eventSchedulerService.GetOnlineCart(tempCart),
                EventCustomerOrderSummaryModel = _eventSchedulerService.GetEventCustomerOrderSummaryModel(guid),
                CustomerEditModel = new SchedulingCustomerEditModel {
                    EnableTexting = _enableTexting
                },
                SourceCodeApplyEditModel = _eventSchedulerService.GetSourceCodeApplied(tempCart),
                RequestValidationModel   = onlineRequestValidationModel
            };
            var newsletterprompt = Convert.ToBoolean(_configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.EnableNewsletterPrompt));

            if (newsletterprompt && model.EventCustomerOrderSummaryModel != null &&
                model.EventCustomerOrderSummaryModel.EventType == EventType.Retail)
            {
                model.RequestForNewsLetterDescription =
                    _toolTipRepository.GetToolTipContentByTag(ToolTipType.OnlineNewsletterDescription);

                model.ShowNewsLetterPrompt = true;
            }

            model.EventCustomerOrderSummaryModel = _eventSchedulerService.GetEventCustomerOrderSummaryModel(guid);
            model.StateList = _stateRepository.GetAllStates().ToList().Select(x => new OrderedPair <long, string>(x.Id, x.Name));

            var customer = tempCart.CustomerId.HasValue ? _customerRepository.GetCustomer(tempCart.CustomerId.Value) : null;

            if (customer == null && tempCart.ProspectCustomerId.HasValue && tempCart.ProspectCustomerId.Value > 0)
            {
                model.CustomerEditModel = _prospectCustomerService.GetforProspectCustomerId(tempCart.ProspectCustomerId.Value);
            }
            else if (customer != null)
            {
                model.CustomerEditModel = Mapper.Map <Customer, SchedulingCustomerEditModel>(customer);
                model.CustomerEditModel.ShippingAddress            = Mapper.Map <Address, AddressEditModel>(customer.Address);
                model.CustomerEditModel.ConfirmationToEnablTexting = customer.EnableTexting;

                //model.CustomerEditModel.ShippingAddress.Id = tempCart.ShippingAddressId.HasValue ? tempCart.ShippingAddressId.Value : 0;
            }

            //payment
            if (model.PaymentEditModel == null)
            {
                model.PaymentEditModel = new PaymentEditModel
                {
                    PaymentFlow = PaymentFlow.In,
                    Amount      = model.EventCustomerOrderSummaryModel.AmountDue.HasValue ? model.EventCustomerOrderSummaryModel.AmountDue.Value : 0,
                    ShippingAddressSameAsBillingAddress = true
                };
            }


            if (customer != null && ((customer.BillingAddress != null && customer.BillingAddress.StreetAddressLine1 != OnlineAddress1) || (customer.Address != null && customer.Address.StreetAddressLine1 != OnlineAddress1)))
            {
                model.PaymentEditModel.ExistingBillingAddress    = Mapper.Map <Address, AddressEditModel>(customer.BillingAddress ?? customer.Address);
                model.PaymentEditModel.ExistingBillingAddress.Id = customer.BillingAddress != null ? customer.BillingAddress.Id : 0;

                model.PaymentEditModel.ExistingShippingAddress    = Mapper.Map <Address, AddressEditModel>(customer.BillingAddress ?? customer.Address);
                model.PaymentEditModel.ExistingShippingAddress.Id = customer.Address != null ? customer.Address.Id : 0;
            }

            model.RequestForNewsLetter = model.EventCustomerOrderSummaryModel != null && model.EventCustomerOrderSummaryModel.EventType == EventType.Retail;

            model.PaymentEditModel.AllowedPaymentTypes = new[] {
                new OrderedPair <long, string>(PaymentType.CreditCard.PersistenceLayerId, PaymentType.CreditCard.Name),
                new OrderedPair <long, string>(PaymentType.ElectronicCheck.PersistenceLayerId, PaymentType.ElectronicCheck.Name),
                new OrderedPair <long, string>(PaymentType.GiftCertificate.PersistenceLayerId, PaymentType.GiftCertificate.Name)
            };

            var payLaterOnlineRegistration = Convert.ToBoolean(_configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.PayLaterOnlineRegistration));

            if (payLaterOnlineRegistration)
            {
                var payLaterOption = new[] { new OrderedPair <long, string>(PaymentType.Onsite_Value, PaymentType.PayLater_Text) };
                model.PaymentEditModel.AllowedPaymentTypes = model.PaymentEditModel.AllowedPaymentTypes.Concat(payLaterOption);
            }

            var eventId      = model.EventCustomerOrderSummaryModel.EventId.HasValue ? model.EventCustomerOrderSummaryModel.EventId.Value : 0;
            var packageId    = model.SourceCodeApplyEditModel.Package != null ? model.SourceCodeApplyEditModel.Package.FirstValue : 0;
            var addOnTestIds = model.SourceCodeApplyEditModel.SelectedTests != null?model.SourceCodeApplyEditModel.SelectedTests.Select(st => st.FirstValue).ToArray() : null;

            var testCoveredByInsurance = _eligibilityService.CheckTestCoveredByinsurance(eventId, packageId, addOnTestIds);

            if (testCoveredByInsurance)
            {
                var insurancePaymentOption = new[] { new OrderedPair <long, string>(PaymentType.Insurance.PersistenceLayerId, PaymentType.Insurance.Name) };
                model.PaymentEditModel.AllowedPaymentTypes = model.PaymentEditModel.AllowedPaymentTypes.Concat(insurancePaymentOption);
            }

            if (model.EventCustomerOrderSummaryModel.AmountDue != null && model.EventCustomerOrderSummaryModel.AmountDue > 0)
            {
                if (payLaterOnlineRegistration)
                {
                    model.PaymentEditModel.Payments = new[]
                    {
                        new PaymentInstrumentEditModel
                        {
                            Amount      = model.EventCustomerOrderSummaryModel.AmountDue.Value,
                            PaymentType = Convert.ToInt32(PaymentType.Onsite_Value)
                        }
                    };
                }
                else
                {
                    model.PaymentEditModel.Payments = new[]
                    {
                        new PaymentInstrumentEditModel
                        {
                            Amount     = model.EventCustomerOrderSummaryModel.AmountDue.Value,
                            ChargeCard = new ChargeCardPaymentEditModel()
                            {
                                ChargeCard = (tempCart.ChargeCardId.HasValue && tempCart.ChargeCardId.Value > 0)
                                                                          ?_chargeCardRepository.GetById(tempCart.ChargeCardId.Value)
                                                                          :new ChargeCard()
                            }
                        }
                    };


                    if (testCoveredByInsurance && tempCart.EligibilityId.HasValue && tempCart.EligibilityId.Value > 0 && tempCart.ChargeCardId.HasValue && tempCart.ChargeCardId.Value > 0)
                    {
                        var insurancePayment = new[]
                        {
                            new PaymentInstrumentEditModel
                            {
                                Insurance = new InsurancePaymentEditModel
                                {
                                    EligibilityId = tempCart.EligibilityId.Value,
                                    ChargeCardId  = tempCart.ChargeCardId.Value
                                }
                            }
                        };
                        model.PaymentEditModel.Payments = model.PaymentEditModel.Payments.Concat(insurancePayment);
                    }
                }
            }
            else
            {
                model.PaymentEditModel.ShippingAddressSameAsBillingAddress = false;
            }

            return(model);
        }