コード例 #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
 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));
 }
コード例 #3
0
        public ActionResult Edit(BeneficiaryViewModel beneficiaryViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            HttpPostedFileBase hasbandphoto = Request.Files["imgupload1"];
            HttpPostedFileBase wifephoto    = Request.Files["imgupload2"];
            //var beniMaster = _benificiaryService.GetBenificiaryById(beneficiaryViewModel.BeneficiaryId);
            var    user   = Session["UserDetails"] as UserViewModel;
            string hphoto = PhotoManager.savePhoto(hasbandphoto, 0, "Benificiary");
            string wphoto = PhotoManager.savePhoto(wifephoto, 0, "Benificiary");

            beneficiaryViewModel.Hasband_Photo = hphoto; //PhotoManager.ConvertToBytes(hasbandphoto);
            beneficiaryViewModel.Wife_Photo    = wphoto; //PhotoManager.ConvertToBytes(wifephoto);
            beneficiaryViewModel.ModifiedBy    = user.UserName;
            beneficiaryViewModel.ModifiedDate  = DateTime.Now;
            beneficiaryViewModel.CityId        = user.CityId;

            var beniMaster = Mapper.BeneficiaryMapper.Attach(beneficiaryViewModel);

            _benificiaryService.Update(beniMaster);
            _benificiaryService.SaveChanges();

            ViewBag.Message = "sussess message";
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        private BeneficiaryDTO Create(BeneficiaryViewModel viewModel)
        {
            try
            {
                log.Debug(BeneficiaryViewModel.FormatBeneficiaryViewModel(viewModel));

                BeneficiaryDTO beneficiary = new BeneficiaryDTO();

                // copy values
                viewModel.UpdateDTO(beneficiary, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                beneficiary.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                beneficiary.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_beneficiaryService.AddBeneficiary - " + BeneficiaryDTO.FormatBeneficiaryDTO(beneficiary));

                int id = _beneficiaryService.AddBeneficiary(beneficiary);

                beneficiary.BeneficiaryId = id;

                log.Debug("result: 'success', id: " + id);

                return(beneficiary);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #5
0
        //useless
        public string SendSms(BeneficiaryViewModel beneficiaryViewModel)
        {
            string msg = "";

            try
            {
                var Link = "http://www.navnirmangroup.org/files/public-docs/app-debug.apk";


                string BeniUserName = beneficiaryViewModel.AdharNo.ToString();
                BeniUserName = !String.IsNullOrWhiteSpace(BeniUserName) && BeniUserName.Length >= 6 ? BeniUserName.Substring(BeniUserName.Length - 6) : BeniUserName;
                var BeniPassword = beneficiaryViewModel.Password;

                string key      = "3r9mqo0k6few3m8";
                string secret   = "mcadq4cuu96g6wp";
                string to       = beneficiaryViewModel.MobileNo;
                string messages = "Click below link to download the App & use credentials for login Username = "******" & Password = "******" " + Link;
                string URL      = "https://www.thetexting.com/rest/sms/json/message/send?api_key=" + key + "&api_secret=" + secret + "&to=" + to + "&text=" + messages;
            }
            catch (Exception ex)
            {
                msg = "Error";
            }
            return(msg);
        }
コード例 #6
0
        /// <summary>
        /// Get Beneficiary by id
        /// </summary>
        /// <param name="id">Beneficiary id</param>
        /// <returns>Beneficiary json view model</returns>
        public IHttpActionResult Get(int id)
        {
            try
            {
                // get
                log.Debug("_beneficiaryService.GetBeneficiary - beneficiaryId: " + id + " ");

                var beneficiary = new BeneficiaryViewModel(_beneficiaryService.GetBeneficiary(id));

                log.Debug("_beneficiaryService.GetBeneficiary - " + BeneficiaryViewModel.FormatBeneficiaryViewModel(beneficiary));

                log.Debug("result: 'success'");

                //return Json(beneficiary, JsonRequestBehavior.AllowGet);
                //return Content(JsonConvert.SerializeObject(beneficiary), "application/json");
                //return beneficiary;
                //return JsonConvert.SerializeObject(beneficiary);
                return(Ok(beneficiary));
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #7
0
 public static Beneficiary ToBeneficiary(this BeneficiaryViewModel beneficiaryViewModel)
 {
     return(new Beneficiary()
     {
         FirstName = beneficiaryViewModel.FirstName,
         MiddleName = beneficiaryViewModel.MiddleName,
         LastName = beneficiaryViewModel.LastName,
     });
 }
コード例 #8
0
        public ActionResult UploadBeneficiayExcel()
        {
            var cities = _cityMasterService.Get(r => r.IsActive == true);
            BeneficiaryViewModel um = new BeneficiaryViewModel();

            um.Cities = cities.Select(s => new SelectListItem {
                Text = s.CityName, Value = s.CityId.ToString()
            }).ToList();
            return(View(um));
        }
コード例 #9
0
        // GET: Beneficiary/Edit/5
        public ActionResult Edit(int id)
        {
            BeneficiaryViewModel beneficiaryViewModel = new BeneficiaryViewModel();
            var beneficiarybyid = _benificiaryService.GetBenificiaryById(id);
            var beneficiaryvm   = Mapper.BeneficiaryMapper.Detach(beneficiarybyid);


            ViewBag.hsbphoto = "/Uploads/BeneficiaryImages/" + beneficiaryvm.Hasband_Photo;
            ViewBag.wfphoto  = "/Uploads/BeneficiaryImages/" + beneficiaryvm.Wife_Photo;
            return(View("Edit", beneficiaryvm));
        }
コード例 #10
0
        public async Task <ActionResult <Customer> > AddBeneficiary(BeneficiaryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Beneficiary beneficiary = _mapper.Map(model, typeof(BeneficiaryViewModel), typeof(Beneficiary)) as Beneficiary;
            var         customer    = await _dbContext.Customers.SingleOrDefaultAsync(c => c.IdentityId == beneficiary.IdentityId);

            beneficiary.Customer = customer;
            await _dbContext.Beneficiaries.AddAsync(beneficiary);

            await _dbContext.SaveChangesAsync();

            return(Created("", customer));
        }
コード例 #11
0
        public ActionResult Create(BeneficiaryViewModel beneficiaryViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                var beniFirstName               = "";
                var mobileNoFirstFour           = "";
                var password                    = "";
                HttpPostedFileBase hasbandphoto = Request.Files["imgupload1"];
                HttpPostedFileBase wifephoto    = Request.Files["imgupload2"];
                var    user   = Session["UserDetails"] as UserViewModel;
                string hphoto = PhotoManager.savePhoto(hasbandphoto, 0, "Benificiary");
                string wphoto = PhotoManager.savePhoto(wifephoto, 0, "Benificiary");
                beneficiaryViewModel.Hasband_Photo = hphoto; //PhotoManager.ConvertToBytes(hasbandphoto);
                beneficiaryViewModel.Wife_Photo    = wphoto; //PhotoManager.ConvertToBytes(wifephoto);
                beneficiaryViewModel.CreatedBy     = user.UserName;
                beneficiaryViewModel.CreatedDate   = DateTime.Now;
                beneficiaryViewModel.CityId        = user.CityId;

                beniFirstName = beneficiaryViewModel.BeneficairyName.ToString();
                beniFirstName = !String.IsNullOrWhiteSpace(beniFirstName) && beniFirstName.Length >= 5 ? beniFirstName.Substring(0, 4) : beniFirstName;

                mobileNoFirstFour = beneficiaryViewModel.MobileNo.ToString();
                mobileNoFirstFour = !String.IsNullOrWhiteSpace(mobileNoFirstFour) && mobileNoFirstFour.Length >= 5 ? mobileNoFirstFour.Substring(0, 4) : mobileNoFirstFour;
                password          = beniFirstName + mobileNoFirstFour; //first four Charactor of first name  and first four digit of mobile no. will be beneficiary's password

                beneficiaryViewModel.Password = password;

                var insertbeneficiary = Mapper.BeneficiaryMapper.Attach(beneficiaryViewModel);

                _benificiaryService.Add(insertbeneficiary);
                _benificiaryService.SaveChanges();

                ViewBag.Message = "Success message";

                //return RedirectToAction("Index");
            }
            catch
            {
            }
            return(View());
        }
コード例 #12
0
        //[ValidateAntiForgeryToken]
        /// <summary>
        /// Updates data for an existing Beneficiary, or creates a new Beneficiary if the Id is 0
        /// </summary>
        /// <param name="viewModel">Beneficiary data</param>
        /// <returns>Beneficiary id</returns>
        public IHttpActionResult Upsert(BeneficiaryViewModel viewModel)
        {
            log.Debug("Upsert");

            if (viewModel.BeneficiaryId > 0)
            {
                var t = Update(viewModel);
                //return Json(true);
                //return JsonConvert.SerializeObject(t.BeneficiaryId);
                return(Ok(t.BeneficiaryId));
            }
            else
            {
                var t = Create(viewModel);
                //return Json(t.BeneficiaryId);
                //return JsonConvert.SerializeObject(t.BeneficiaryId);
                return(Ok(t.BeneficiaryId));
            }
        }
コード例 #13
0
        private BeneficiaryDTO Update(BeneficiaryViewModel viewModel)
        {
            try
            {
                log.Debug(BeneficiaryViewModel.FormatBeneficiaryViewModel(viewModel));

                // get
                log.Debug("_beneficiaryService.GetBeneficiary - beneficiaryId: " + viewModel.BeneficiaryId + " ");

                var existingBeneficiary = _beneficiaryService.GetBeneficiary(viewModel.BeneficiaryId);

                log.Debug("_beneficiaryService.GetBeneficiary - " + BeneficiaryDTO.FormatBeneficiaryDTO(existingBeneficiary));

                if (existingBeneficiary != null)
                {
                    // copy values
                    viewModel.UpdateDTO(existingBeneficiary, null); //RequestContext.Principal.Identity.GetUserId());

                    // update
                    log.Debug("_beneficiaryService.UpdateBeneficiary - " + BeneficiaryDTO.FormatBeneficiaryDTO(existingBeneficiary));

                    _beneficiaryService.UpdateBeneficiary(existingBeneficiary);

                    log.Debug("result: 'success'");
                }
                else
                {
                    log.Error("existingBeneficiary: null, BeneficiaryId: " + viewModel.BeneficiaryId);
                }

                return(existingBeneficiary);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #14
0
        //[ValidateAntiForgeryToken]
        /// <summary>
        /// Save a list of Beneficiary
        /// </summary>
        /// <param name="viewModels">Beneficiary view models</param>
        /// <param name="id">(not used)</param>
        /// <returns>true if the operation is successfull</returns>
        public IHttpActionResult SaveList(BeneficiaryViewModel[] viewModels, int?id)
        {
            try
            {
                log.Debug("SaveList");

                if (viewModels != null)
                {
                    // save list
                    foreach (BeneficiaryViewModel viewModel in viewModels)
                    {
                        log.Debug(BeneficiaryViewModel.FormatBeneficiaryViewModel(viewModel));

                        if (viewModel.BeneficiaryId > 0)
                        {
                            var t = Update(viewModel);
                        }
                        else
                        {
                            var t = Create(viewModel);
                        }
                    }
                }
                else
                {
                    log.Error("viewModels: null");
                }

                //return Json(true);
                //return JsonConvert.SerializeObject(true);
                return(Ok(true));
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #15
0
        public static BenificiaryMaster Attach(BeneficiaryViewModel beneficiaryViewModel)
        {
            BenificiaryMaster beneficiaryMaster = new BenificiaryMaster();

            beneficiaryMaster.BeneficiaryId   = beneficiaryViewModel.BeneficiaryId;
            beneficiaryMaster.Hasband_Photo   = beneficiaryViewModel.Hasband_Photo;
            beneficiaryMaster.Wife_Photo      = beneficiaryViewModel.Wife_Photo;
            beneficiaryMaster.BeneficairyName = beneficiaryViewModel.BeneficairyName;
            beneficiaryMaster.FatherName      = beneficiaryViewModel.FatherName;
            beneficiaryMaster.Mother          = beneficiaryViewModel.Mother;
            beneficiaryMaster.MobileNo        = beneficiaryViewModel.MobileNo;
            beneficiaryMaster.CityId          = beneficiaryViewModel.CityId;
            beneficiaryMaster.DTRNo           = beneficiaryViewModel.DTRNo;
            beneficiaryMaster.RecordNo        = beneficiaryViewModel.RecordNo;
            beneficiaryMaster.Class           = beneficiaryViewModel.Class;
            beneficiaryMaster.General         = beneficiaryViewModel.General;
            beneficiaryMaster.Single          = beneficiaryViewModel.Single;
            beneficiaryMaster.Disabled        = beneficiaryViewModel.Disabled;
            beneficiaryMaster.Password        = beneficiaryViewModel.Password;
            beneficiaryMaster.AdharNo         = beneficiaryViewModel.AdharNo;
            beneficiaryMaster.VoterID         = beneficiaryViewModel.VoterID;
            beneficiaryMaster.Area            = beneficiaryViewModel.Area;
            beneficiaryMaster.MojaNo          = beneficiaryViewModel.MojaNo;
            beneficiaryMaster.KhataNo         = beneficiaryViewModel.KhataNo;
            beneficiaryMaster.KhasraNo        = beneficiaryViewModel.KhasraNo;
            beneficiaryMaster.PlotNo          = beneficiaryViewModel.PlotNo;
            beneficiaryMaster.PoliceStation   = beneficiaryViewModel.PoliceStation;
            beneficiaryMaster.WardNo          = beneficiaryViewModel.WardNo;
            beneficiaryMaster.District        = beneficiaryViewModel.District;
            beneficiaryMaster.BankName        = beneficiaryViewModel.BankName;
            beneficiaryMaster.BranchName      = beneficiaryViewModel.BranchName;
            beneficiaryMaster.IFSCCode        = beneficiaryViewModel.IFSCCode;
            beneficiaryMaster.AccountNo       = beneficiaryViewModel.AccountNo;
            beneficiaryMaster.CreatedBy       = beneficiaryViewModel.CreatedBy;
            beneficiaryMaster.CreatedDate     = DateTime.Now;
            beneficiaryMaster.CompanyID       = beneficiaryViewModel.CompanyID;

            //beneficiaryMaster.InstallmentDetails = beneficiaryViewModel.InstallmentDetails.Select(s => new InstallmentDetail { BeneficiaryId = s.BeneficiaryId, StageID = s.StageID, CreatedDate = DateTime.Now, CreatedBy= s.CreatedBy }).ToList();
            return(beneficiaryMaster);
        }
コード例 #16
0
 public CaseViewModel()
 {
     Patrono      = new EmployerViewModel();
     Direccion    = new AddressViewModel();
     Beneficiario = new BeneficiaryViewModel();
 }
コード例 #17
0
        public string applyToAddBen(string IDNum, BeneficiaryViewModel model, string reason)
        {
            string feedback = "Request unsuccessfull";

            using (var Holder = new PolicyHolderRepository())
            {
                PolicyHolder member = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
                if (member != null)// if member was found
                {
                    var rb = new RegisterBusiness();
                    using (var ProfileAppBenRep = new ProfileApplicationBeneficiaryRepository())
                    {     //start using ProfileApplicationBeneficiaryRepository
                        if (ProfileAppBenRep.Find(x => x.benIDNumber == model.benIDNumber).SingleOrDefault() == null)
                        { //start if there's no beneficiary found
                            //application here
                            ProfileApplicationBeneficiary ben = new ProfileApplicationBeneficiary()
                            {
                                benIDNumber  = model.benIDNumber,
                                IDNumber     = IDNum,
                                firstName    = model.firstName,
                                lastName     = model.lastName,
                                relationship = model.relationship,
                                age          = rb.calcAge(model.benIDNumber),
                                AddOrDelete  = "Add",
                                reason       = reason
                            };
                            //Validate the age range of the beneficiary
                            if (ben.age >= 65)
                            {
                                return("We cannot cover a beneficiary of more than 65 years of age");
                            }
                            if (ben.relationship == "Spouse")
                            {
                                if (ben.age < 18)
                                {
                                    return("Spouse must be at least 18 years of age");
                                }
                            }
                            //Compare the Beneficiarie's age with the Policy holder based on their relationship
                            if (ben.relationship == "Parent" || ben.relationship == "Grandparent" || ben.relationship == "Parent-in-law")
                            {
                                if (ben.age < (rb.calcAge(member.IDNumber)))
                                {
                                    return("Parent cannot be younger than the Applicant");
                                }
                                else if (ben.age == (rb.calcAge(member.IDNumber)))
                                {
                                    return("Parent cannot be at the same age as the Applicant");
                                }
                                else if (ben.age > rb.calcAge(member.IDNumber) && (ben.age - rb.calcAge(member.IDNumber)) < 13)
                                {
                                    return("Parent must be at least 13 years older than the Applicant");
                                }
                            }
                            if (ben.relationship == "Uncle" || ben.relationship == "Aunt")
                            {
                                if (ben.age < (rb.calcAge(member.IDNumber)))
                                {
                                    return("Uncle or Aunt cannot be younger than the Applicant");
                                }
                                else if (ben.age == (rb.calcAge(member.IDNumber)))
                                {
                                    return("Uncle or Aunt cannot be at the same age as the Applicant");
                                }
                                else if (ben.age > rb.calcAge(member.IDNumber) && (ben.age - rb.calcAge(member.IDNumber)) < 5)
                                {
                                    return("Uncle or Aunt must be at least 5 years older than the Applicant");
                                }
                            }
                            if (ben.relationship == "Child" || ben.relationship == "Grandchild")
                            {
                                if (ben.age > (rb.calcAge(member.IDNumber)))
                                {
                                    return("Child cannot be older than you, " + member.firstName);
                                }
                                else if (ben.age == (rb.calcAge(member.IDNumber)))
                                {
                                    return("Child cannot be at the same age as the Applicant");
                                }
                                else if (ben.age < rb.calcAge(member.IDNumber) && (rb.calcAge(member.IDNumber) - ben.age) < 13)
                                {
                                    return("Applicant must be at least 13 years older than the Child");
                                }
                            }
                            //We can now create an application
                            ProfileAppBenRep.Insert(ben);
                            //Record this in the event log
                            try
                            {
                                using (var eventLog = new ProfileActivityLogRepository())
                                {
                                    ProfileActivityLog pal = new ProfileActivityLog()
                                    {
                                        IDNumber  = IDNum,
                                        EventDate = DateTime.Now,
                                        Activity  = "Applied to Add " + ben.firstName + " " + ben.lastName + "as you beneficiary"
                                    };
                                    eventLog.Insert(pal);
                                }
                            }
                            catch (Exception ex) { feedback += ex; }
                            feedback = "Request successfull, look forward to recieve a report in 3 to 5 working days.";

                            //Let's generate the required supporting documents
                            using (var padr = new ProfileApplicationDocumentsRepository())
                            {
                                if (ben.relationship == "Spouse")
                                {
                                    ProfileApplicationDocuments doc = new ProfileApplicationDocuments()
                                    {
                                        PolicyHolderIDN = member.IDNumber,
                                        IDNumber        = member.IDNumber,
                                        fullname        = member.firstName + " " + member.lastName,
                                        documentName    = "Marriage Certificate",
                                        document        = null,
                                    };
                                    padr.Insert(doc);
                                    ProfileApplicationDocuments docmnt = new ProfileApplicationDocuments()
                                    {
                                        PolicyHolderIDN = member.IDNumber,
                                        IDNumber        = ben.IDNumber,
                                        fullname        = ben.firstName + " " + ben.lastName,
                                        documentName    = "ID Document",
                                        document        = null,
                                    };
                                    padr.Insert(docmnt);
                                }
                                else if (ben.age >= 21)
                                {
                                    ProfileApplicationDocuments docmnt = new ProfileApplicationDocuments()
                                    {
                                        PolicyHolderIDN = member.IDNumber,
                                        IDNumber        = ben.IDNumber,
                                        fullname        = ben.firstName + " " + ben.lastName,
                                        documentName    = "ID Document",
                                        document        = null,
                                    };
                                    padr.Insert(docmnt);
                                    ProfileApplicationDocuments doc = new ProfileApplicationDocuments()
                                    {
                                        PolicyHolderIDN = member.IDNumber,
                                        IDNumber        = ben.benIDNumber,
                                        fullname        = ben.firstName + " " + ben.lastName,
                                        documentName    = "Institutional Proof of Registration | (Full time study)",
                                        document        = null,
                                    };
                                    padr.Insert(doc);
                                }
                                else if (ben.age < 18)
                                {
                                    ProfileApplicationDocuments doc = new ProfileApplicationDocuments()
                                    {
                                        PolicyHolderIDN = member.IDNumber,
                                        IDNumber        = ben.benIDNumber,
                                        fullname        = ben.firstName + " " + ben.lastName,
                                        documentName    = "Birth Certificate",
                                        document        = null,
                                    };
                                    padr.Insert(doc);
                                }
                                else if (ben.age >= 18 && ben.age < 21)
                                {
                                    ProfileApplicationDocuments doc = new ProfileApplicationDocuments()
                                    {
                                        PolicyHolderIDN = member.IDNumber,
                                        IDNumber        = ben.benIDNumber,
                                        fullname        = ben.firstName + " " + ben.lastName,
                                        documentName    = "ID Document",
                                        document        = null,
                                    };
                                    padr.Insert(doc);
                                }
                            } //---End  using ProfileApplicationDocumentsRepository
                        }     //---End if there's no beneficiary found
                        feedback = "ID Number already exist!";
                    }         //---End using ProfileApplicationBeneficiaryRepository
                }             //---End if member was found
                else
                {
                    feedback = "An Error occured while proccessing your request.";
                }
            }//End using PolicyHolderRepository
            return(feedback);
        }
コード例 #18
0
        public void addBeneficiary(BeneficiaryViewModel model, string ID)
        {
            var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository();

            if (BenefitiaryArepo.Find(x => x.benIDNumber == model.benIDNumber).SingleOrDefault() == null)
            {
                ClientApplicationBeneficiary ben = new ClientApplicationBeneficiary()
                {
                    benIDNumber  = model.benIDNumber,
                    IDNumber     = ID,
                    firstName    = model.firstName,
                    lastName     = model.lastName,
                    relationship = model.relationship,
                    age          = calcAge(model.benIDNumber)
                };

                var ClientArepo          = new ClientApplicationRepository();
                var CADocRepo            = new ClientApplicationDocumentRepository();
                ClientApplication client = ClientArepo.Find(x => x.IDNumber == ID).SingleOrDefault();
                if (ben.age >= 65)
                {
                    feedback = "We cannot cover a beneficiary of more than 65 years of age";
                    return;
                }
                if (ben.relationship == "Spouse")
                {
                    if (ben.age < 18)
                    {
                        feedback = "Spouse must be at least 18 years of age";
                        return;
                    }
                }

                if (ben.relationship == "Parent" || ben.relationship == "Grandparent" || ben.relationship == "Parent-in-law")
                {
                    if (ben.age < (calcAge(client.IDNumber)))
                    {
                        feedback = "Parent cannot be younger than the Applicant";
                        return;
                    }
                    else if (ben.age == (calcAge(client.IDNumber)))
                    {
                        feedback = "Parent cannot be at the same age as the Applicant";
                        return;
                    }
                    else if (ben.age > calcAge(client.IDNumber) && (ben.age - calcAge(client.IDNumber)) < 13)
                    {
                        feedback = "Parent must be at least 13 years older than the Applicant";
                        return;
                    }
                }
                if (ben.relationship == "Uncle" || ben.relationship == "Aunt")
                {
                    if (ben.age < (calcAge(client.IDNumber)))
                    {
                        feedback = "Uncle or Aunt cannot be younger than the Applicant";
                        return;
                    }
                    else if (ben.age == (calcAge(client.IDNumber)))
                    {
                        feedback = "Uncle or Aunt cannot be at the same age as the Applicant";
                        return;
                    }
                    else if (ben.age > calcAge(client.IDNumber) && (ben.age - calcAge(client.IDNumber)) < 5)
                    {
                        feedback = "Uncle or Aunt must be at least 5 years older than the Applicant";
                        return;
                    }
                }
                if (ben.relationship == "Child" || ben.relationship == "Grandchild")
                {
                    if (ben.age > (calcAge(client.IDNumber)))
                    {
                        feedback = "Child cannot be older than you, " + client.firstName;
                        return;
                    }
                    else if (ben.age == (calcAge(client.IDNumber)))
                    {
                        feedback = "Child cannot be at the same age as the Applicant";
                        return;
                    }
                    else if (ben.age < calcAge(client.IDNumber) && (calcAge(client.IDNumber) - ben.age) < 13)
                    {
                        feedback = "Applicant must be at least 13 years older than the Child";
                        return;
                    }
                }
                BenefitiaryArepo.Insert(ben);

                if (ben.relationship == "Spouse")
                {
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = client.IDNumber,
                        fullname      = client.firstName + " " + client.lastName,
                        documentName  = "Marriage Certificate",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                    ClientApplicationDocument docmnt = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.IDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "ID Document",
                        document      = null,
                    };
                    CADocRepo.Insert(docmnt);
                }
                else if (ben.age >= 21)
                {
                    ClientApplicationDocument docmnt = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.IDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "ID Document",
                        document      = null,
                    };
                    CADocRepo.Insert(docmnt);
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.benIDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "Institutional Proof of Registration | (Full time study)",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                }
                else if (ben.age < 18)
                {
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.benIDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "Birth Certificate",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                }
                else if (ben.age >= 18 && ben.age < 21)
                {
                    ClientApplicationDocument doc = new ClientApplicationDocument()
                    {
                        applicationID = client.applicationID,
                        IDNumber      = ben.benIDNumber,
                        fullname      = ben.firstName + " " + ben.lastName,
                        documentName  = "ID Document",
                        document      = null,
                    };
                    CADocRepo.Insert(doc);
                }
            }
            else
            {
                feedback = "ID Number already exist!";
            }
        }
 public BeneficiaryPage()
 {
     InitializeComponent();
     BindingContext = _vm = new BeneficiaryViewModel(Navigation);
 }
コード例 #20
0
        public ActionResult UploadBeneficiayExcel(HttpPostedFileBase postedFile, BeneficiaryViewModel beneficiaryViewModel)
        {
            var cities = _cityMasterService.Get(r => r.IsActive == true);
            BeneficiaryViewModel um = new BeneficiaryViewModel();

            um.Cities = cities.Select(s => new SelectListItem {
                Text = s.CityName, Value = s.CityId.ToString()
            }).ToList();

            if (postedFile == null)
            {
                ViewBag.Success = "postedFile is Null";
                return(View(um));
            }

            try
            {
                int?   cityId   = beneficiaryViewModel.CityId;
                var    userData = Session["UserDetails"] as UserViewModel;
                string filePath = string.Empty;
                if (postedFile != null)
                {
                    string path = Server.MapPath("~/Uploads/UploadedExcels/");

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    filePath = path + Path.GetFileName(postedFile.FileName);
                    string extension = Path.GetExtension(postedFile.FileName);
                    postedFile.SaveAs(filePath);

                    string conStr = string.Empty;
                    switch (extension)
                    {
                    case ".xls":
                        conStr = ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString;
                        break;

                    case ".xlsx":
                        conStr = ConfigurationManager.ConnectionStrings["Excel07ConString"].ConnectionString;
                        break;
                    }

                    DataTable dt = new DataTable();
                    conStr = string.Format(conStr, filePath);

                    //Add data from excel to dt for validation
                    using (OleDbConnection conStrExcel = new OleDbConnection(conStr))
                    {
                        using (OleDbCommand cmdExcel = new OleDbCommand())
                        {
                            using (OleDbDataAdapter daExcel = new OleDbDataAdapter())
                            {
                                cmdExcel.Connection = conStrExcel;
                                conStrExcel.Open();
                                DataTable dtExcelSchema;
                                dtExcelSchema = conStrExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                                string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
                                conStrExcel.Close();

                                conStrExcel.Open();
                                cmdExcel.CommandText  = "SELECT * From [" + sheetName + "]";
                                daExcel.SelectCommand = cmdExcel;
                                daExcel.Fill(dt);
                                conStrExcel.Close();
                            }
                        }
                    }

                    //Code for get only 6 digit of adhaar no and remove single quote from adhaar and DTR no
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        var NewAdhaarNo  = dt.Rows[i]["AdharNo"].ToString();
                        var NewDTRNo     = dt.Rows[i]["DTRNo"].ToString();
                        var NewAccountNo = dt.Rows[i]["AccountNo"].ToString();
                        NewAdhaarNo             = NewAdhaarNo.Substring(NewAdhaarNo.Length - 6);
                        NewDTRNo                = NewDTRNo.Replace("'", "");
                        NewAccountNo            = NewAccountNo.Replace("'", "");
                        dt.Rows[i]["AdharNo"]   = NewAdhaarNo;
                        dt.Rows[i]["DTRNo"]     = NewDTRNo;
                        dt.Rows[i]["AccountNo"] = NewAccountNo;
                    }
                    //dt.Columns["AdharNo"]=

                    //add new columns to existing datatable
                    dt.Columns.Add("CreatedDate", typeof(System.DateTime));
                    dt.Columns.Add("CreatedBy", typeof(System.String));
                    dt.Columns.Add("CompanyID", typeof(System.Int32));
                    dt.Columns.Add("Password", typeof(System.String));
                    dt.Columns.Add("CityId", typeof(System.Int32));

                    var    password          = "";
                    var    beniFirstName     = "";
                    var    mobileNoFirstFour = "";
                    string error             = "";

                    StringBuilder sb = new StringBuilder();

                    //validate data by looping before upload
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["CityId"].ToString() == "")
                        {
                            dt.Rows[i]["CityId"] = cityId;
                        }
                        if (dt.Rows[i]["CreatedDate"].ToString() == "")
                        {
                            dt.Rows[i]["CreatedDate"] = DateTime.Now;
                        }
                        if (dt.Rows[i]["CreatedBy"].ToString() == "")
                        {
                            dt.Rows[i]["CreatedBy"] = "System";
                        }
                        if (dt.Rows[i]["CompanyID"].ToString() == "")
                        {
                            dt.Rows[i]["CompanyID"] = userData.CompanyID;
                        }
                        if (dt.Rows[i]["BeneficairyName"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter Beneficiary Name in row " + RowNo);
                            error += "Please enter Beneficiary Name in row " + RowNo + Environment.NewLine;
                        }
                        else
                        {
                            beniFirstName = dt.Rows[i]["BeneficairyName"].ToString();
                            beniFirstName = !String.IsNullOrWhiteSpace(beniFirstName) && beniFirstName.Length >= 5 ? beniFirstName.Substring(0, 4) : beniFirstName;
                        }
                        if (dt.Rows[i]["FatherName"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter Father Name in row " + RowNo);
                            error += "Please enter Father Name in row " + RowNo + Environment.NewLine;
                        }
                        if (dt.Rows[i]["MobileNo"].ToString() == "")
                        {
                            var mobileno = dt.Rows[i]["MobileNo"].GetType();
                            int RowNo    = i + 2;
                            sb.AppendLine("Please enter Mobile No in row " + RowNo);
                            error += "Please enter Mobile No in row " + RowNo + Environment.NewLine;
                        }
                        else
                        {
                            mobileNoFirstFour = dt.Rows[i]["MobileNo"].ToString();
                            mobileNoFirstFour = !String.IsNullOrWhiteSpace(mobileNoFirstFour) && mobileNoFirstFour.Length >= 5 ? mobileNoFirstFour.Substring(0, 4) : mobileNoFirstFour;
                        }

                        #region this Code commented and remain for if client want to add city id from excel data

                        //if (dt.Rows[i]["CityName"].ToString() == "")
                        //{
                        //    int RowNo = i + 2;
                        //    ViewBag.WrongBeniData = "Please enter City Name in row " + RowNo;
                        //    return View(um);
                        //}
                        //else
                        //{
                        //    dt.Rows[i]["CityName"] = cityId;
                        //}
                        //else
                        //{
                        //    var cityName = dt.Rows[i]["CityName"].ToString();
                        //    var cityId = 0;
                        //    cityId = _cityMasterService.Get().Where(c => c.CityName == cityName).Select(c => c.CityId).FirstOrDefault();
                        //    if(cityId != 0)
                        //    {
                        //        dt.Rows[i]["CityName"] = cityId;
                        //    }
                        //    else
                        //    {
                        //        int RowNo = i + 2;
                        //        ViewBag.WrongBeniData = "Invalid City Name in row " + RowNo; //City Name must be exact same as saved in database
                        //        return View(um);
                        //    }
                        //}
                        #endregion

                        if (dt.Rows[i]["DTRNo"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter DTR No in row " + RowNo);
                            error += "Please enter DTR No in row " + RowNo + Environment.NewLine;
                        }
                        //if (dt.Rows[i]["General"].ToString() == "")
                        //{
                        //    int RowNo = i + 2;
                        //    sb.AppendLine("Please enter Cast in row " + RowNo);
                        //    error += "Please enter Cast in row " + RowNo + Environment.NewLine;
                        //}
                        if (dt.Rows[i]["AdharNo"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter Adhar No in row " + RowNo);
                            error += "Please enter Adhar No in row " + RowNo + Environment.NewLine;
                        }
                        if (dt.Rows[i]["BankName"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter Bank Name in row " + RowNo);
                            error += "Please enter Bank Name in row " + RowNo + Environment.NewLine;
                        }
                        if (dt.Rows[i]["BranchName"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter Branch Name in row " + RowNo);
                            error += "Please enter Branch Name in row " + RowNo + Environment.NewLine;
                        }
                        if (dt.Rows[i]["IFSCCode"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter IFSC Code in row " + RowNo);
                            error += "Please enter IFSC Code in row " + RowNo + Environment.NewLine;
                        }
                        if (dt.Rows[i]["BankName"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter BankName in in row " + RowNo);
                            error += "Please enter BankName in in row " + RowNo + Environment.NewLine;
                        }
                        if (dt.Rows[i]["AccountNo"].ToString() == "")
                        {
                            int RowNo = i + 2;
                            sb.AppendLine("Please enter Account No in in row " + RowNo);
                            error += "Please enter Account No in in row " + RowNo + Environment.NewLine;
                        }
                        password = beniFirstName + mobileNoFirstFour;
                        if (dt.Rows[i]["Password"].ToString() == "")
                        {
                            dt.Rows[i]["Password"] = password;
                        }
                    }

                    //show blank data cells if exists in dt
                    if (!string.IsNullOrWhiteSpace(sb.ToString()))
                    {
                        ViewBag.WrongBeniData = sb.ToString().Replace(Environment.NewLine, "\n");
                        return(View(um));
                    }

                    //indert data into DB from dt
                    conStr = ConfigurationManager.ConnectionStrings["ErrorLog"].ConnectionString;
                    using (SqlConnection con = new SqlConnection(conStr))
                    {
                        con.Open();
                        using (SqlTransaction sqlTransaction = con.BeginTransaction())
                        {
                            using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(conStr))
                            {
                                sqlBulkCopy.DestinationTableName = "BenificiaryMaster";

                                //Mapping with excel and sql
                                sqlBulkCopy.ColumnMappings.Add("BeneficairyName", "[BeneficairyName]");
                                sqlBulkCopy.ColumnMappings.Add("FatherName", "[FatherName]");
                                sqlBulkCopy.ColumnMappings.Add("Mother", "[Mother]");
                                sqlBulkCopy.ColumnMappings.Add("MobileNo", "[MobileNo]");
                                sqlBulkCopy.ColumnMappings.Add("PresentAddress", "[PresentAddress]");
                                sqlBulkCopy.ColumnMappings.Add("CityId", "[CityId]");
                                sqlBulkCopy.ColumnMappings.Add("DTRNo", "[DTRNo]");
                                sqlBulkCopy.ColumnMappings.Add("RecordNo", "[RecordNo]");
                                sqlBulkCopy.ColumnMappings.Add("Class", "[Class]");
                                sqlBulkCopy.ColumnMappings.Add("General", "[General]");
                                sqlBulkCopy.ColumnMappings.Add("Single", "[Single]");
                                sqlBulkCopy.ColumnMappings.Add("Disabled", "[Disabled]");
                                sqlBulkCopy.ColumnMappings.Add("Password", "[Password]");
                                sqlBulkCopy.ColumnMappings.Add("AdharNo", "[AdharNo]");
                                sqlBulkCopy.ColumnMappings.Add("VoterID", "[VoterID]");
                                sqlBulkCopy.ColumnMappings.Add("Area", "[Area]");
                                sqlBulkCopy.ColumnMappings.Add("MojaNo", "[MojaNo]");
                                sqlBulkCopy.ColumnMappings.Add("KhataNo", "[KhataNo]");
                                sqlBulkCopy.ColumnMappings.Add("KhasraNo", "[KhasraNo]");
                                sqlBulkCopy.ColumnMappings.Add("PlotNo", "[PlotNo]");
                                sqlBulkCopy.ColumnMappings.Add("PoliceStation", "[PoliceStation]");
                                sqlBulkCopy.ColumnMappings.Add("WardNo", "[WardNo]");
                                sqlBulkCopy.ColumnMappings.Add("District", "[District]");
                                sqlBulkCopy.ColumnMappings.Add("BankName", "[BankName]");
                                sqlBulkCopy.ColumnMappings.Add("BranchName", "[BranchName]");
                                sqlBulkCopy.ColumnMappings.Add("IFSCCode", "[IFSCCode]");
                                sqlBulkCopy.ColumnMappings.Add("AccountNo", "[AccountNo]");
                                sqlBulkCopy.ColumnMappings.Add("CreatedDate", "[CreatedDate]");
                                sqlBulkCopy.ColumnMappings.Add("CreatedBy", "[CreatedBy]");
                                //sqlBulkCopy.ColumnMappings.Add("ModifiedDate", "[ModifiedDate]");
                                //sqlBulkCopy.ColumnMappings.Add("ModifiedBy", "[ModifiedBy]");
                                sqlBulkCopy.ColumnMappings.Add("CompanyID", "[CompanyID]");
                                //sqlBulkCopy.ColumnMappings.Add("Wife_Photo", "[Wife_Photo]");
                                //sqlBulkCopy.ColumnMappings.Add("Hasband_Photo", "[Hasband_Photo]");

                                try
                                {
                                    sqlBulkCopy.WriteToServer(dt);
                                    sqlTransaction.Commit();
                                    ViewBag.Success = "Data Improted successfully";
                                }
                                catch (Exception ex)
                                {
                                    sqlTransaction.Rollback();
                                    ViewBag.WrongBeniData = "Kindly check the uploaded excel data, there is some proble with the format type or data";
                                    return(View(um));
                                }
                            }
                        }
                        con.Close();
                    }
                }
                return(View(um));
            }
            catch (Exception ex)
            {
                ViewBag.WrongBeniData = ex.Message;
                return(View(um));
            }
        }
コード例 #21
0
        public static CaseViewModel CreateFrom(CaseDetail caseDetail, decimal?balance, CaseDetail caseMain = null, decimal?balanceLesionado = null)
        {
            var model = new CaseViewModel();

            DateTime now = DateTime.Now;

            model.CaseId                   = caseDetail.CaseId.Value;
            model.CaseDetailId             = caseDetail.CaseDetailId;
            model.NumeroCaso               = caseDetail.CaseNumber;
            model.NumeroCasoMostrado       = string.Format("{0} {1}", caseDetail.CaseNumber, caseDetail.CaseKey);
            model.CaseKey                  = caseDetail.CaseKey;
            model.FechaRadicacion          = caseDetail.Case.CaseDate.HasValue ? caseDetail.Case.CaseDate.Value.ToShortDateString() : string.Empty;
            model.FechaAccidente           = caseDetail.Case.AccidentDate.HasValue ? caseDetail.Case.AccidentDate.Value.ToShortDateString() : string.Empty;
            model.Region                   = caseDetail.Case.Region == null ? string.Empty : caseDetail.Case.Region.Region1;
            model.Dispensario              = caseDetail.Case.Clinic == null ? string.Empty : caseDetail.Case.Clinic.Clinic1;
            model.CasoMenor                = caseDetail.Case.IsMinor.GetValueOrDefault(false);
            model.CasoMuerte               = caseDetail.Case.DeathFlag.GetValueOrDefault(false);
            model.TipoIncapacidad          = caseDetail.Case.Concept == null ? string.Empty : caseDetail.Case.Concept.Concept1;
            model.TienePerentorio          = caseDetail.Transactions.Any(t => t.TransactionTypeId == 4);
            model.TieneInversionMenor3     = caseDetail.Transactions.Any(t => t.TransactionTypeId == 3 && (t.TransactionDate.HasValue && t.TransactionDate.Value.AddYears(3) > now));
            model.FechaAccidenteMenor1984  = caseDetail.Case.AccidentDate.HasValue ? (caseDetail.Case.AccidentDate.Value < new DateTime(1984, 5, 30)) : false;
            model.TienePagoTercerosVigente = caseDetail.ThirdPartySchedules.Any(t => !t.TerminationDate.HasValue || (t.TerminationDate.Value < now));
            model.DiasSemana               = caseDetail.Case.DaysWeek.GetValueOrDefault(0);
            model.CompSemanal              = caseDetail.Case.WeeklyComp.GetValueOrDefault(decimal.Zero);
            model.CompSemanalInca          = caseDetail.Case.WeeklyCompDisability.GetValueOrDefault(decimal.Zero);
            model.FechaSuspension          = caseDetail.CancellationDate.HasValue ? caseDetail.CancellationDate.Value.ToShortDateString() : string.Empty;
            model.RazonSuspension          = caseDetail.Cancellation.IsNull() ? string.Empty : caseDetail.Cancellation.Cancellation1;
            model.FechaReanudacion         = caseDetail.RestartDate.HasValue ? caseDetail.RestartDate.Value.ToShortDateString() : string.Empty;
            model.FromCase                 = caseDetail.CaseFolderId.HasValue ? true : false;
            model.CaseFolderId             = caseDetail.CaseFolderId.IsNull() ? 0 : caseDetail.CaseFolderId;


            if (caseDetail.CancellationDate.HasValue)
            {
                model.PaymentStatus = "Suspendido";
            }
            else
            {
                if (caseDetail.ActiveIdent.IsNullOrEmpty())
                {
                    model.PaymentStatus = "Activo";
                }
                else
                {
                    if (caseDetail.ActiveIdent.Contains("A"))
                    {
                        if (!caseDetail.Cancellation.IsNull())
                        {
                            if (caseDetail.Cancellation.CancellationCode.Contains("A") ||
                                caseDetail.Cancellation.CancellationCode.Contains("C") ||
                                caseDetail.Cancellation.CancellationCode.Contains("T"))
                            {
                                model.PaymentStatus = "Suspendido";
                            }
                            else
                            {
                                model.PaymentStatus = "Activo";
                            }
                        }
                        else
                        {
                            model.PaymentStatus = "Activo";
                        }
                    }
                    else if (caseDetail.ActiveIdent.Contains("I"))
                    {
                        model.PaymentStatus = "Inactivo";
                    }
                    else if (caseDetail.ActiveIdent.Contains("S"))
                    {
                        model.PaymentStatus = "Suspendido";
                    }
                }
            }

            if (caseDetail.Entity == null)
            {
                model.Lesionado       = string.Empty;
                model.SSN             = string.Empty;
                model.FechaNacimiento = string.Empty;
                model.EsBeneficiario  = false;
                model.EsLesionado     = false;
            }
            else
            {
                model.EntityId       = caseDetail.EntityId.Value;
                model.EsLesionado    = caseDetail.Entity.ParticipantTypeId == 8;
                model.EsBeneficiario = caseDetail.Entity.ParticipantTypeId == 4;


                if (model.EsBeneficiario && !caseMain.IsNull())
                {
                    model.Lesionado       = caseMain.Entity.FullName;
                    model.SSN             = caseMain.Entity.SSN.ToSSN();
                    model.FechaNacimiento = caseMain.Entity.BirthDate.HasValue ? caseMain.Entity.BirthDate.Value.ToShortDateString() : string.Empty;

                    if (caseMain.Entity.Addresses.Any())
                    {
                        var addressPostal = caseMain.Entity.Addresses.Where(a => a.AddressTypeId == 2).FirstOrDefault();
                        if (addressPostal != null)
                        {
                            model.Direccion = AddressViewModel.CreateFrom(addressPostal);
                        }
                    }
                    else
                    {
                        model.Direccion = new AddressViewModel();
                    }

                    model.EBT               = caseMain.EBTAccount.IsNull() ? string.Empty : caseMain.EBTAccount;
                    model.EBTStatus         = caseMain.EBTStatus.IsNull() ? string.Empty : caseMain.EBTStatus;
                    model.EBTBalance        = caseMain.EBTBalance.IsNull() ? 0 : caseMain.EBTBalance;
                    model.BalanceFormateado = balanceLesionado.HasValue ? balanceLesionado.Value.ToCurrency() : string.Empty;
                }
                else
                {
                    model.Lesionado       = caseDetail.Entity.FullName;
                    model.SSN             = caseDetail.Entity.SSN.ToSSN();
                    model.FechaNacimiento = caseDetail.Entity.BirthDate.HasValue ? caseDetail.Entity.BirthDate.Value.ToShortDateString() : string.Empty;

                    if (caseDetail.Entity.Addresses.Any())
                    {
                        var addressPostal = caseDetail.Entity.Addresses.Where(a => a.AddressTypeId == 2).FirstOrDefault();
                        if (addressPostal != null)
                        {
                            model.Direccion = AddressViewModel.CreateFrom(addressPostal);
                        }
                    }
                    else
                    {
                        model.Direccion = new AddressViewModel();
                    }
                    model.EBT               = caseDetail.EBTAccount.IsNull() ? string.Empty : caseDetail.EBTAccount;
                    model.EBTStatus         = caseDetail.EBTStatus.IsNull() ? string.Empty : caseDetail.EBTStatus;
                    model.EBTBalance        = caseDetail.EBTBalance.IsNull() ? 0 : caseDetail.EBTBalance;
                    model.BalanceFormateado = balanceLesionado.HasValue ? balanceLesionado.Value.ToCurrency() : string.Empty;
                }
            }

            model.Patrono             = EmployerViewModel.CreateFrom(caseDetail.Case);
            model.Beneficiario        = BeneficiaryViewModel.CreateFrom(caseDetail, balance);
            model.Balance             = balance;
            model.AdjudicacionInicial = caseDetail.GetInitialAllocation();
            model.TieneAbogado        = !caseDetail.EntityId_Lawyer.IsNull();

            return(model);
        }