public ClientApplication getApplicant(string id) { using (var ClientArepo = new ClientApplicationRepository()) { return(ClientArepo.Find(x => x.IDNumber == id).First()); } }
public void createPolicyHolder(int appID) { var CArepo = new ClientApplicationRepository(); try { ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table PolicyHolder ph = new PolicyHolder() //initialise the client as policy holder { IDNumber = client.IDNumber, title = client.title, firstName = client.firstName, lastName = client.lastName, province = client.province, contactNumber = client.contactNumber, emailAdress = client.emailAdress, physicalAddress = client.physicalAddress, postalAddress = client.postalAddress, packageID = client.packageID, dateStarted = DateTime.Now, status = "Active" }; using (var polRepo = new PolicyHolderRepository()) { polRepo.Insert(ph); //Save as policy holder var rolb = new RoleBusiness(); rolb.AddUserToRole(ph.IDNumber, "Policy Holder"); } } catch (Exception ex) { feedback = "Request unsuccessfull"; } }
public ClientApplication getApplicationByIDNumber(string ID) { using (var CArepo = new ClientApplicationRepository()) { return(CArepo.Find(x => x.IDNumber == ID).FirstOrDefault()); } }
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); } } }
public void AppStatusUpdate(string id) { using (var ClientArepo = new ClientApplicationRepository()) { ClientApplication client = ClientArepo.Find(x => x.IDNumber == id).SingleOrDefault(); client.status = "Proccessing"; ClientArepo.Update(client); } }
public void ChoosePackage(int packID, string id) { using (var CArepo = new ClientApplicationRepository()) { ClientApplication client = CArepo.Find(x => x.IDNumber == id).SingleOrDefault(); client.packageID = packID; CArepo.Update(client); } }
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 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 DeclineApplication(int appID, string reason) { try { using (var CArepo = new ClientApplicationRepository()) { ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); client.status = "Unsuccessfull : " + reason; removeDocs(appID); removeBenef(client.IDNumber); //send email } } catch (Exception ex) { feedback = "Request unsuccessfull"; } }
public List <ClientApplicationDocument> OutstandingDocList(string id) { if (id == null) { feedback = "Bad request"; return(null); } var ClientArepo = new ClientApplicationRepository(); ClientApplication client = ClientArepo.Find(x => x.IDNumber == id).SingleOrDefault(); var CADocRepo = new ClientApplicationDocumentRepository(); var docList = (from x in CADocRepo.GetAll() where x.applicationID == client.applicationID select x).ToList(); return(docList); //list of supporting documents }
public void ApproveApplication(int appID) { try { createPolicyHolder(appID); using (var CArepo = new ClientApplicationRepository()) { ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); createBeneficiaries(client.IDNumber); createDocuments(appID); //removeDocs(appID); //removeBenef(client.IDNumber); } } catch (Exception ex) { feedback = "Request unsuccessfull"; } }
//Add Personal information public void CreateApplication(RegisterModel objRegisterModel) { try { ClientApplication capp = new ClientApplication { IDNumber = objRegisterModel.identityNumber, title = objRegisterModel.title, firstName = objRegisterModel.firstName, lastName = objRegisterModel.lastName, province = objRegisterModel.province, contactNumber = objRegisterModel.contactNumber, emailAdress = objRegisterModel.Email, physicalAddress = renderPhysicalAddressSave(objRegisterModel.streetAddress, objRegisterModel.suburb, objRegisterModel.city, objRegisterModel.postalCode.ToString()), packageID = 1, dateSubmitted = DateTime.Now, status = "Awaiting outstanding supporting documents" }; if (objRegisterModel.postalOffice == null) { capp.postalAddress = renderPhysicalAddressSave(objRegisterModel.streetAddress, objRegisterModel.suburb, objRegisterModel.city, objRegisterModel.postalCode.ToString()); } else { capp.postalAddress = renderPostalAddressSave(objRegisterModel.postalOffice, objRegisterModel.town, objRegisterModel.boxpostalCode); } using (var CArepo = new ClientApplicationRepository()) { CArepo.Insert(capp); ClientApplication client = CArepo.Find(x => x.IDNumber == capp.IDNumber).SingleOrDefault(); ClientApplicationDocument docmnt = new ClientApplicationDocument() { applicationID = client.applicationID, IDNumber = client.IDNumber, fullname = client.firstName + " " + client.lastName, documentName = "ID Document", document = null, }; using (var CADocRepo = new ClientApplicationDocumentRepository()) { CADocRepo.Insert(docmnt); } ClientApplicationDocument doc = new ClientApplicationDocument() { applicationID = client.applicationID, IDNumber = client.IDNumber, fullname = client.firstName + " " + client.lastName, documentName = "Signed Policy Document", document = null, }; using (var CADocRepo = new ClientApplicationDocumentRepository()) { CADocRepo.Insert(doc); } feedback = "We recieved your Personal Information, please indicate your Beneficiaries."; //send email } } catch (Exception ex) { feedback += " : " + ex; } }
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!"; } }