Example #1
0
        public void UpdateModelFromDto(PolicyDTO policy, BicycleQuote model)
        {
            model.PolicyNumber = policy.PolicyNumber;

            if (policy.Contact != null)
            {
                model.PolicyDetail.Contact.FirstName     = policy.Contact.FirstName;
                model.PolicyDetail.Contact.LastName      = policy.Contact.LastName;
                model.PolicyDetail.Contact.DateOfBirth   = policy.Contact.DateOfBirth.HasValue ? new DateData(policy.Contact.DateOfBirth.Value) : null;
                model.PolicyDetail.Contact.ContactEmail  = policy.Contact.EmailAddress;
                model.PolicyDetail.Contact.ContactNumber = policy.Contact.PhoneNumber;

                if (policy.Contact.Address != null)
                {
                    model.PolicyDetail.Contact.Address  = policy.Contact.Address.AddressLine1;
                    model.PolicyDetail.Contact.Suburb   = policy.Contact.Address.Suburb;
                    model.PolicyDetail.Contact.PostCode = policy.Contact.Address.PostCode;
                }
            }

            BicycleQuoteQuoteOption option = new BicycleQuoteQuoteOption
            {
                Description     = "Bike Insurance",
                IsSelected      = true,
                PolicyStartDate = DateUtil.CurrentDateTime.ToString("dd MMMM yyyy")
            };

            if (policy.Option != null)
            {
                //
                // values are mandatory in the database, therefore we can make the assumption that they are set.
                // they are also set as [Required] in the policy, so no idea why they are defined as nullable types.
                //
                option.AnnualPremium    = (decimal)policy.Option.AnnualPremium.GetValueOrDefault();
                option.Excess           = (decimal)policy.Option.Excess.GetValueOrDefault();
                option.Code             = policy.Option.Code;
                option.SumInsured.Value = (int)Convert.ToDecimal(policy.Option.AgreedValue);


                model.PolicyPayment.PaymentDetails.PaymentMethod    = 1;
                model.PolicyPayment.PaymentDetails.PaymentFrequency = 1;
                model.PolicyPayment.PaymentDetails.Excess           = $"{policy.Option.Excess.GetValueOrDefault():C2}";
                model.PolicyPayment.PaymentDetails.Premium          = $"{policy.Option.AnnualPremium.GetValueOrDefault():C2}";

                model.PolicyPayment.PaymentDetails.PolicyStartDate = DateUtil.CurrentDateTime.ToString("dd MMMM yyyy");
            }

            model.Quote.Options = new List <BicycleQuoteQuoteOption> {
                option
            };

            if (policy.Payment != null)
            {
                // TODO : it's been paid, do we need to do anything here?!?
            }
        }
Example #2
0
        public virtual async Task <ActionResult> UpdateSelectedProduct(FormCollection formValues)
        {
            ViewModelPolicy <BicycleQuote> quote = new ViewModelPolicy <BicycleQuote>();

            TryUpdateModel(quote);

            ViewData.SetViewModelBase(quote.ViewModel);

            IList <BicycleQuoteQuoteOption> products = quote.ViewModel.Quote.Options;
            BicycleQuoteQuoteOption         product  = products.FirstOrDefault(x => x.IsSelected);

            ViewBag.Index = products.IndexOf(product);

            return(PartialView("PremiumContainer", quote.ViewModel));
        }