public List <ProfileApplicationView> getApplications() { using (var ProfileAppBenRep = new ProfileApplicationBeneficiaryRepository()) { using (var ProfileAppDocRep = new ProfileApplicationDocumentsRepository()) { return(ProfileAppBenRep.GetAll().Select(x => new ProfileApplicationView() { beneficiaryID = x.beneficiaryID, benIDNumber = x.benIDNumber, IDNumber = x.IDNumber, firstName = x.firstName, lastName = x.lastName, relationship = x.relationship, age = x.age, AddOrDelete = x.AddOrDelete, reason = x.reason, documents = ProfileAppDocRep.GetAll().Select(d => new ProfileApplicationDocuments() { documentID = d.documentID, IDNumber = d.IDNumber, documentName = d.documentName, document = d.document, fullname = d.fullname, PolicyHolderIDN = d.PolicyHolderIDN }).ToList() }).ToList()); } } }
public void replace(int idDoc) { using (var padr = new ProfileApplicationDocumentsRepository()) { var doc = padr.GetById(idDoc); doc.document = null; padr.Update(doc); } }
public DocumentViewModel getPersonIn_Docs(int id) { DocumentViewModel model = new DocumentViewModel(); using (var padr = new ProfileApplicationDocumentsRepository()) { var doc = padr.GetById(id); model.documentID = doc.documentID; model.IDNumber = doc.IDNumber; model.fullname = doc.fullname; model.documentName = doc.documentName; model.document = doc.document; } return(model); }
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 }
public void UploadDocument(DocumentViewModel model) { try { using (var padr = new ProfileApplicationDocumentsRepository()) { ProfileApplicationDocuments PADoc = padr.Find(x => x.IDNumber == model.IDNumber && x.fullname == model.fullname && x.documentName == model.documentName).SingleOrDefault(); PADoc.documentID = PADoc.documentID; PADoc.PolicyHolderIDN = model.IDNumber; PADoc.IDNumber = model.IDNumber; PADoc.fullname = model.fullname; PADoc.documentName = model.documentName; PADoc.document = model.document; padr.Update(PADoc); } } catch (Exception ex) { } }
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); }