public void removeBenef(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) { BenefitiaryArepo.Archive(ben); } }
public List <ClientApplicationBeneficiary> getBeneficiariesByAppID(int appID) { var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository(); var ClientArepo = new ClientApplicationRepository(); ClientApplication client = ClientArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client List <ClientApplicationBeneficiary> cab = new List <ClientApplicationBeneficiary>(); cab = (from cl in ClientArepo.GetAll() join ben in BenefitiaryArepo.GetAll() on cl.IDNumber equals ben.IDNumber where ben.IDNumber == client.IDNumber select ben).ToList(); return(cab); }
public List <ClientApplicationBeneficiary> getBeneficiariesByClientID(string ID) { var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository(); var ClientArepo = new ClientApplicationRepository(); List <ClientApplicationBeneficiary> cab = new List <ClientApplicationBeneficiary>(); cab = (from cl in ClientArepo.GetAll() join ben in BenefitiaryArepo.GetAll() on cl.IDNumber equals ben.IDNumber where ben.IDNumber == ID select ben).ToList(); return(cab); }
public ApplicationViewModel getApplication(int appID) { var CArepo = new ClientApplicationRepository(); ApplicationViewModel appView = new ApplicationViewModel(); try { ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table appView.applicationID = appID; appView.IDNumber = client.IDNumber; appView.title = client.title; appView.firstName = client.firstName; appView.lastName = client.lastName; appView.province = client.province; appView.contactNumber = client.contactNumber; appView.emailAdress = client.emailAdress; appView.physicalAddress = client.physicalAddress; appView.postalAddress = client.postalAddress; using (var pac = new PackageRepository()) { appView.packageID = pac.GetById(client.packageID).Name; } appView.dateSubmitted = client.dateSubmitted; appView.status = client.status; var BenefitiaryArepo = new ClientApplicationBeneficiaryRepository(); var benList = (from ben in BenefitiaryArepo.GetAll() where ben.IDNumber == client.IDNumber select ben).ToList(); foreach (var ben in benList) { appView.beneficiaries.Add(ben); } var CADocRepo = new ClientApplicationDocumentRepository(); var docList = (from x in CADocRepo.GetAll() where x.applicationID == appID select x).ToList(); foreach (var doc in docList) { appView.documents.Add(doc); } } catch (Exception ex) { feedback = "Request unsuccessfull"; } return(appView); }
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); } } }
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!"; } }