Example #1
0
        public void createDocuments(int appID)
        {
            var CADocRepo = new ClientApplicationDocumentRepository();
            var docList   = (from x in CADocRepo.GetAll()
                             where x.applicationID == appID
                             select x).ToList();

            var CArepo = new ClientApplicationRepository();
            ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table
            var polRepo = new PolicyHolderRepository();

            foreach (var doc in docList)
            {
                using (var polDocRepo = new PolicyDocumentRepository())
                {
                    PolicyDocument pd = new PolicyDocument()
                    {
                        policyNo     = polRepo.Find(x => x.IDNumber == client.IDNumber).SingleOrDefault().policyNo,
                        IDNumber     = doc.IDNumber,
                        fullname     = doc.fullname,
                        documentName = doc.documentName,
                        document     = doc.document
                    };
                    polDocRepo.Insert(pd);
                }
            }
        }
Example #2
0
        //Updating
        public string updateContactDetails(string IDNum, ContactDetailsViewModel model)
        {
            string feedback = "Request unsuccessfull";

            using (var Holder = new PolicyHolderRepository())
            {
                var          rb     = new RegisterBusiness();
                PolicyHolder member = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
                if (member != null)
                {
                    member.contactNumber   = model.contactNumber;
                    member.physicalAddress = rb.renderPhysicalAddressSave(model.streetAddress, model.suburb, model.city, model.postalCode.ToString());
                    member.postalAddress   = rb.renderPostalAddressSave(model.postalOffice, model.town, model.boxpostalCode);
                    Holder.Update(member);
                    try
                    {
                        using (var eventLog = new ProfileActivityLogRepository())
                        {
                            ProfileActivityLog pal = new ProfileActivityLog()
                            {
                                IDNumber  = IDNum,
                                EventDate = DateTime.Now,
                                Activity  = "Contact Information was updated"
                            };
                            eventLog.Insert(pal);
                        }
                    }
                    catch (Exception ex) { feedback += ex; }
                    feedback = "Contact Information changed";
                }
            }
            return(feedback);
        }
Example #3
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);
     }
 }
Example #4
0
 //Viewing Profile
 public PersonalInfoViewModel getPersonalInfo(string IDNum)
 {
     using (var Holder = new PolicyHolderRepository())
     {
         PolicyHolder member       = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
         var          PersonalInfo = new PersonalInfoViewModel();
         if (member != null)
         {
             PersonalInfo.IDNumber    = member.IDNumber;
             PersonalInfo.firstName   = member.firstName;
             PersonalInfo.lastName    = member.lastName;
             PersonalInfo.province    = member.province;
             PersonalInfo.title       = member.title;
             PersonalInfo.spouse      = getSpouse(IDNum);
             PersonalInfo.dateOfBirth = getDateOfBirth(IDNum);
             PersonalInfo.gender      = getGender(IDNum);
         }
         return(PersonalInfo);
     }
 }
Example #5
0
 public List <ProfileApplicationDocuments> OutstandingDocList(string IDNum)
 {
     if (IDNum != null)
     {
         using (var Holder = new PolicyHolderRepository())
         {
             PolicyHolder member = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
             if (member != null)// if member was found
             {
                 using (var padr = new ProfileApplicationDocumentsRepository())
                 {
                     return((from x in padr.GetAll()
                             where x.PolicyHolderIDN == member.IDNumber
                             select x).ToList());
                 }
             }
         }
     }
     return(new List <ProfileApplicationDocuments>());
     //list of supporting documents
 }
Example #6
0
 public ContactDetailsViewModel getContactDetails(string IDNum)
 {
     using (var Holder = new PolicyHolderRepository())
     {
         PolicyHolder member         = Holder.Find(x => x.IDNumber == IDNum).FirstOrDefault();
         var          ContactDetails = new ContactDetailsViewModel();
         var          rb             = new RegisterBusiness();
         if (member != null)
         {
             ContactDetails.contactNumber = member.contactNumber;
             ContactDetails.emailAdress   = member.emailAdress;
             ContactDetails.streetAddress = rb.renderStreetView(member.physicalAddress);
             ContactDetails.suburb        = rb.renderSuburbView(member.physicalAddress);
             ContactDetails.city          = rb.renderCityView(member.physicalAddress);
             ContactDetails.postalCode    = Convert.ToInt16(rb.renderPostalView(member.physicalAddress));
             ContactDetails.postalOffice  = rb.renderPOView(member.postalAddress);
             ContactDetails.town          = rb.renderTownView(member.postalAddress);
             ContactDetails.boxpostalCode = rb.renderPostalOBView(member.postalAddress);
         }
         return(ContactDetails);
     }
 }
Example #7
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);
        }
Example #8
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);
        }