public List<Applicant> SearchApplicant(ApplicantSearch request)
        {
            IQueryable<Applicant> applicantQuery = context.Applicants;

            //Trim down which Applicant Loan Request's we're looking for)
            if (!string.IsNullOrEmpty(request.Firstname))
                applicantQuery = applicantQuery.Where(a => a.FirstName.StartsWith(request.Firstname));

            if (!string.IsNullOrEmpty(request.Lastname))
                applicantQuery = applicantQuery.Where(a => a.LastName.StartsWith(request.Lastname));

            if (!string.IsNullOrEmpty(request.Email))
                applicantQuery = applicantQuery.Where(a => a.Contacts.Any(c => c.ContactDetail.StartsWith(request.Email) && c.ContactTypeId == (int)ContactsOfType.EmailAddress));

            if (!string.IsNullOrEmpty(request.Mobile))
                applicantQuery = applicantQuery.Where(a => a.Contacts.Any(c => c.ContactDetail.StartsWith(request.Mobile) && c.ContactTypeId == (int)ContactsOfType.MobilePhone));

            if (!string.IsNullOrEmpty(request.Postcode))
                applicantQuery = applicantQuery.Where(app => app.Addresses.Any(ha => ha.Postcode.StartsWith(request.Postcode)));

            //Card number search special cause not displaying it on the page
            if (!string.IsNullOrEmpty(request.CardNumber))
            {
                applicantQuery = applicantQuery.Where(a => a.BankCards.Any(b => b.CardNumber.StartsWith(request.CardNumber)));
            }

            List<Applicant> applicants = (from app in applicantQuery
                                          join applicant in context.Applicants on app.ApplicantId equals
                                              applicant.ApplicantId
                                          select applicant).ToList();

            return applicants;
        }
Beispiel #2
0
        public List<Applicant> SearchApplicant(ApplicantSearch searchObj)
        {
            List<Applicant> applicants = new List<Applicant>();

            applicants = _applicantRepository.SearchApplicant(searchObj);

            return applicants;
        }
        public ActionResult Index(ApplicantSearch model)
        {
            model.Applicants= _applicantService.SearchApplicant(model);

            return View(model);
        }
 public ActionResult Index()
 {
     ApplicantSearch model = new ApplicantSearch();
     model.Applicants = new List<Applicant>();
     return View(model);
 }