Ejemplo n.º 1
0
        public ActionResult CalculatePremium(PolicyDetailsViewModel model)
        {
            //Validate inputs
            if (!ModelState.IsValid)
            {
                //return index with populated valued and error messages
                model.Occupations = GetOccupations();
                return(View("Index", model));
            }

            var driverAge     = GetDriverAgeAtPolicyStartDate((DateTime)model.DriverDateOfBirth, (DateTime)model.PolicyStartDate);
            var declineReason = CheckIfPolicyDeclined((DateTime)model.PolicyStartDate, driverAge);

            //return policy declined if declineReason exists
            if (!string.IsNullOrEmpty(declineReason))
            {
                var policyDeclinedModel = new PolicyDeclinedViewModel
                {
                    PolicyDeclinedReason = declineReason
                };

                return(View("PolicyDeclined", policyDeclinedModel));
            }

            //calculate premium
            var premiumCalculatedViewModel = new PremiumCalculatedViewModel();

            premiumCalculatedViewModel.Premium = CalculatePremium(model.DriverOccupationID, driverAge);

            return(View(premiumCalculatedViewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var model = new PolicyDetailsViewModel();

            model.Occupations = GetOccupations();
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Details(int id)
        {
            var policy       = _context.Policies.SingleOrDefault(c => c.ID == id);
            var policyholder = _context.Subscribers.SingleOrDefault(c => c.SubscriberID == policy.SubscriberId);
            var statuses     = _context.PolicyStatuses;

            if (policy == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new PolicyDetailsViewModel()
            {
                Policy     = policy,
                Subscriber = policyholder
            };

            return(View(viewModel));
        }
Ejemplo n.º 4
0
 public PolicyDetailsViewModel getPolicyDetails(string IDNum)
 {
     using (var Holder = new PolicyHolderRepository())
     {
         PolicyHolder member        = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
         var          PolicyDetails = new PolicyDetailsViewModel();
         if (member != null)
         {
             PolicyDetails.dateStarted = member.dateStarted;
             using (var pac = new PackageRepository())
             {
                 PolicyDetails.packageName = pac.GetById(member.packageID).Name;
             }
             PolicyDetails.policyNo = member.policyNo;
             PolicyDetails.status   = member.status;
         }
         return(PolicyDetails);
     }
 }
Ejemplo n.º 5
0
 public PolicyDetails(string policyNumber)
 {
     InitializeComponent();
     this.policyNumber = policyNumber;
     BindingContext    = policyDetailsViewModel = new PolicyDetailsViewModel();
 }
Ejemplo n.º 6
0
 public PolicyList()
 {
     InitializeComponent();
     BindingContext = policyListViewModel = new PolicyDetailsViewModel();
 }