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));
 }
 public ActionResult applyToAddBeneficiary(BeneficiaryViewModel model, string reason)
 {
     if (ModelState.IsValid)
     {
         var pb       = new PackageBusiness();
         var profileB = new ProfileBusiness();
         for (int x = 0; x < pb.GetAll().Count; x++)
         {
             //find the Policy Holder's package
             if (pb.GetAll()[x].PackageId == pb.GetByName(profileB.getPolicyDetails(HttpContext.User.Identity.Name).packageName).PackageId)
             {
                 //if we haven't reached the maximum number the package can cover, add the beneficiary
                 if (profileB.getBeneficiaries(HttpContext.User.Identity.Name).Count < pb.GetByName(profileB.getPolicyDetails(HttpContext.User.Identity.Name).packageName).maxBeneficiary)
                 {
                     TempData["Error"] = profileB.applyToAddBen(HttpContext.User.Identity.Name, model, reason);
                     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("attachDocuments"));
     }
     return(View(model));
 }
Exemple #3
0
 public ActionResult GetAll()
 {
     return(View(prepo.GetAll()));
 }