예제 #1
0
 public ActionResult AddBeneficiary(BeneficiaryViewModel model)
 {
     if (ModelState.IsValid)
     {
         var objRB = new RegisterBusiness();
         ViewBag.List = objRB.getBeneficiariesByClientID(HttpContext.User.Identity.Name);
         var pb = new PackageBusiness();
         for (int x = 0; x < pb.GetAll().Count; x++)
         {
             //find the Applicant's package
             if (pb.GetAll()[x].PackageId == pb.GetById(objRB.getApplicant(HttpContext.User.Identity.Name).packageID).PackageId)
             {
                 //if we haven't reached the maximum number the package can cover, add the beneficiary
                 if (objRB.getBeneficiariesByClientID(HttpContext.User.Identity.Name).Count < pb.GetById(objRB.getApplicant(HttpContext.User.Identity.Name).packageID).maxBeneficiary)
                 {
                     objRB.addBeneficiary(model, HttpContext.User.Identity.Name);
                     TempData["Error"] = RegisterBusiness.feedback;
                     break;
                 }
                 else //otherwise return an alert to the user
                 {
                     TempData["Error"] = pb.GetAll()[x].Name + " package can cover up to " + pb.GetAll()[x].maxBeneficiary + " beneficiaries";
                 }
             }
         }
         return(RedirectToAction("ReloadBen"));
     }
     return(View(model));
 }
예제 #2
0
        //Get : AddPackageBenefit
        public ActionResult AddPackageBenefits(int?packID)
        {
            if (packID == null)
            {
                return(HttpNotFound());
            }
            var pb  = new PackageBusiness();
            var pbv = new Template.Model.ViewModels.PackageBenefitView();

            pbv.benefit               = new List <Template.Model.ViewModels.BenefitView>();
            pbv.benefit               = pb.GetAllBenefits();
            Session["packID"]         = packID;
            Session["Name"]           = pb.GetById((int)packID).Name;
            Session["PremiumAmount"]  = pb.GetById((int)packID).PremiumAmount;
            Session["maxBeneficiary"] = pb.GetById((int)packID).maxBeneficiary;

            List <BenefitView> benefit = new List <BenefitView>();

            benefit = pb.GetAllBenefits();
            return(View(benefit));
        }
예제 #3
0
 public ActionResult EditPackage(int id)
 {
     return(View(prepo.GetById(id)));
 }