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); } } }
//Updates the document public void replace(int idDoc) { using (var CADocRepo = new ClientApplicationDocumentRepository()) { var doc = CADocRepo.GetById(idDoc); doc.document = null; CADocRepo.Update(doc); } }
public List <ClientApplicationDocument> AttachedDocList(int appID) { var ClientArepo = new ClientApplicationRepository(); var CADocRepo = new ClientApplicationDocumentRepository(); var docList = (from x in CADocRepo.GetAll() where x.applicationID == appID select x).ToList(); return(docList); //list of supporting documents }
public void removeDocs(int appID) { var CADocRepo = new ClientApplicationDocumentRepository(); var docList = (from x in CADocRepo.GetAll() where x.applicationID == appID select x).ToList(); foreach (var doc in docList) { CADocRepo.Delete(doc); } }
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 DocumentViewModel getPersonIn_Docs(int id) { DocumentViewModel model = new DocumentViewModel(); using (var CADocRepo = new ClientApplicationDocumentRepository()) { var doc = CADocRepo.GetById(id); model.documentID = doc.documentID; model.applicationID = doc.applicationID; model.IDNumber = doc.IDNumber; model.fullname = doc.fullname; model.documentName = doc.documentName; model.document = doc.document; } return(model); }
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 string UploadDocument(DocumentViewModel model) { try { using (var CADocRepo = new ClientApplicationDocumentRepository()) { ClientApplicationDocument CADoc = CADocRepo.Find(x => x.IDNumber == model.IDNumber && x.fullname == model.fullname && x.documentName == model.documentName).SingleOrDefault(); CADoc.documentID = CADoc.documentID; CADoc.applicationID = model.applicationID; CADoc.IDNumber = model.IDNumber; CADoc.documentName = model.documentName; CADoc.document = model.document; CADocRepo.Update(CADoc); } } catch (Exception ex) { feedback = "Unable to upload documents, our servers are currently down, please try again."; } return(feedback); }
public byte[] doc(int id) { var CADocRepo = new ClientApplicationDocumentRepository(); return(CADocRepo.GetById(id).document); }
//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!"; } }