Пример #1
0
 public BeneficiariesViewModel getOneBeneficiary(string benefIDNum)
 {
     using (var ben = new PolicyBeneficiaryRepository())
     {
         var beneficiary = ben.GetAll().Find(x => x.benIDNumber == benefIDNum);
         return(new BeneficiariesViewModel()
         {
             benIDNumber = beneficiary.benIDNumber,
             firstName = beneficiary.firstName,
             lastName = beneficiary.lastName,
             relationship = beneficiary.relationship,
             age = beneficiary.age
         });
     }
 }
Пример #2
0
 public List <BeneficiariesViewModel> getBeneficiaries(string IDNum)
 {
     using (var ben = new PolicyBeneficiaryRepository())
     {
         var Beneficiaries = (from i in ben.GetAll()
                              where i.IDNumber == IDNum
                              select i).ToList();
         return(Beneficiaries.Select(x => new BeneficiariesViewModel()
         {
             benIDNumber = x.benIDNumber,
             firstName = x.firstName,
             lastName = x.lastName,
             relationship = x.relationship,
             age = x.age
         }).ToList());
     }
 }
Пример #3
0
        public string getSpouse(string IDNum)
        {
            string name = "";

            using (var ben = new PolicyBeneficiaryRepository())
            {
                name = "Married to " +
                       (from i in ben.GetAll()
                        where i.IDNumber == IDNum && i.relationship == "Spouse"
                        select i.firstName + " " + i.lastName).FirstOrDefault();
                if (name == "Married to ")
                {
                    name = "Not specified";
                }
            }
            return(name);
        }
Пример #4
0
        public void createBeneficiaries(string IDNum)
        {
            var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository();
            var benList          = (from ben in BenefitiaryArepo.GetAll()
                                    where ben.IDNumber == IDNum
                                    select ben).ToList();

            foreach (var ben in benList)
            {
                PolicyBeneficiary pb = new PolicyBeneficiary()
                {
                    benIDNumber  = ben.benIDNumber,
                    IDNumber     = ben.IDNumber,
                    firstName    = ben.firstName,
                    lastName     = ben.lastName,
                    relationship = ben.relationship,
                    age          = ben.age
                };
                using (var polBenRepo = new PolicyBeneficiaryRepository())
                {
                    polBenRepo.Insert(pb);
                }
            }
        }
Пример #5
0
        //Applying
        public string applyToRemoveBen(string IDNum, string benefIDNum, string reason)
        {
            string feedback = "Request unsuccessfull : ";

            using (var Holder = new PolicyHolderRepository())
            {
                PolicyHolder member = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
                if (member != null)
                {
                    using (var ben = new PolicyBeneficiaryRepository())
                    {
                        var Beneficiary = (from i in ben.GetAll()
                                           where i.IDNumber == IDNum && i.benIDNumber == benefIDNum
                                           select i).FirstOrDefault();
                        if (Beneficiary != null)
                        {
                            //application here
                            using (var prof = new ProfileApplicationBeneficiaryRepository())
                            {
                                ProfileApplicationBeneficiary pab = new ProfileApplicationBeneficiary()
                                {
                                    IDNumber     = IDNum,
                                    benIDNumber  = Beneficiary.benIDNumber,
                                    firstName    = Beneficiary.firstName,
                                    lastName     = Beneficiary.lastName,
                                    relationship = Beneficiary.relationship,
                                    age          = Beneficiary.age,
                                    AddOrDelete  = "Remove",
                                    reason       = reason
                                };
                                prof.Insert(pab);
                                //Record this in the event log
                                try
                                {
                                    using (var eventLog = new ProfileActivityLogRepository())
                                    {
                                        ProfileActivityLog pal = new ProfileActivityLog()
                                        {
                                            IDNumber  = IDNum,
                                            EventDate = DateTime.Now,
                                            Activity  = "Applied to Remove " + Beneficiary.firstName + " " + Beneficiary.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.";
                            }
                        }
                        else
                        {
                            feedback = "Error while proccessing your request";
                        }
                    }
                }
                else
                {
                    feedback += " Something went wrong!";
                }
            }
            return(feedback);
        }