/// <summary> /// this method will search permit based on search parameters /// </summary> async void SearchPermits() { var permits = await _dataService.GetPermitByStatus(SearchPermitStatus); List <PermitModel> filteredPermits = new List <PermitModel>(); if ((string.IsNullOrEmpty(ApplicantName) && string.IsNullOrEmpty(AffidavitNumber))) { filteredPermits = (from t1 in permits where (t1.Permit.DateIssued.Value.Date >= DateTime.Parse(DateIssuedFrom).Date&& t1.Permit.DateIssued.Value.Date <= DateTime.Parse(DateIssuedTo).Date) && t1.Permit.PermitApplicant.Name.ToLower().Contains(ApplicantName.ToLower()) || t1.Permit.AffidavitID.Value.Equals(AffidavitNumber) orderby t1.Permit.DateIssued descending select t1).ToList(); } else { filteredPermits = (from t1 in permits where (t1.Permit.DateIssued.Value.Date >= DateTime.Parse("06/22/2017").Date&& t1.Permit.DateIssued.Value.Date <= DateTime.Parse(DateIssuedTo).Date) && t1.Permit.PermitApplicant.Name.ToLower().Contains(ApplicantName.ToLower()) || t1.Permit.AffidavitID.Value.Equals(AffidavitNumber) orderby t1.Permit.DateIssued descending select t1).ToList(); if (!string.IsNullOrEmpty(ApplicantName)) { CCBNumber = string.Empty; if (!string.IsNullOrEmpty(AffidavitNumber)) { filteredPermits = filteredPermits.Where(x => (x.Applicant.Name.ToUpper().Contains(ApplicantName.ToUpper())) && (x.Permit.AffidavitID.Value.ToString().Contains(AffidavitNumber))).ToList(); } else { filteredPermits = filteredPermits.Where(x => x.Applicant.Name.ToUpper().Contains(ApplicantName.ToUpper())).ToList(); } } //else if (!string.IsNullOrEmpty(CCBNumber)) //{ // ApplicantName = string.Empty; // if (!string.IsNullOrEmpty(AffidavitNumber)) // { // filteredPermits = filteredPermits.Where(x => (x.Permit.BuilderBoardNo.Contains(CCBNumber)) && (x.Permit.AffidavitID.Value.ToString().Contains(AffidavitNumber))).ToList(); // } // else // { // filteredPermits = filteredPermits.Where(x => x.Permit.BuilderBoardNo.Contains(CCBNumber)).ToList(); // } //} else if (string.IsNullOrEmpty(ApplicantName) && !string.IsNullOrEmpty(AffidavitNumber)) { filteredPermits = filteredPermits.Where(x => x.Permit.AffidavitID.Value.ToString().Contains(AffidavitNumber)).ToList(); } } //filteredPermits.AddRange(permits.Where(x => x.Permit.DateIssued.Value.Date >= DateTime.Parse(DateIssuedFrom).Date && x.Permit.DateIssued.Value.Date <= DateTime.Parse(DateIssuedTo).Date || x.Permit.PermitApplicant.Name.ToLower().Contains(ApplicantName.ToLower()) || x.Permit.AffidavitID.Value.Equals(AffidavitNumber)).ToList()); ApprovedPermits = new ObservableCollection <PermitModel>(filteredPermits.Distinct().ToList()); }
async void SearchPermits() { var permits = await _dataService.GetPermitByStatus("Submitted"); List <PermitModel> filteredPermits = new List <PermitModel>(); //filteredPermits = (from t1 in filteredPermits // orderby t1.filteredPermits.DateIssued descending // select t1).ToList(); if (!string.IsNullOrEmpty(ApplicantName)) { CCBNumber = string.Empty; if (!string.IsNullOrEmpty(AffidavitNumber)) { filteredPermits = permits.Where(x => (x.Applicant.Name.ToLower().Contains(ApplicantName.ToLower())) && (x.Permit.AffidavitID.Value.ToString().Contains(AffidavitNumber))).ToList(); } else { filteredPermits = permits.Where(x => x.Applicant.Name.ToLower().Contains(ApplicantName.ToLower())).ToList(); } } else if (!string.IsNullOrEmpty(CCBNumber)) { ApplicantName = string.Empty; if (!string.IsNullOrEmpty(AffidavitNumber)) { filteredPermits = permits.Where(x => (x.Permit.BuilderBoardNo.Contains(CCBNumber.ToUpper())) && (x.Permit.AffidavitID.Value.ToString().Contains(AffidavitNumber))).ToList(); } else { filteredPermits = permits.Where(x => x.Permit.BuilderBoardNo.Contains(CCBNumber.ToUpper())).ToList(); } } else if (string.IsNullOrEmpty(ApplicantName) && string.IsNullOrEmpty(CCBNumber) && !string.IsNullOrEmpty(AffidavitNumber)) { filteredPermits = permits.Where(x => x.Permit.AffidavitID.Value.ToString().Contains(AffidavitNumber)).ToList(); } if (filteredPermits.Count > 0) { SubmittedPermits = new ObservableCollection <PermitModel>(filteredPermits.Distinct().ToList()); } else { SubmittedPermits = permits; } }
async void SearchPermitsForLastOneWeek() { var permits = await _dataService.GetPermitByStatus(SearchPermitStatus); List <PermitModel> filteredPermits = new List <PermitModel>(); filteredPermits = (from t1 in permits where (t1.Permit.DateIssued.Value.Date >= DateTime.Parse(DateIssuedFrom).Date&& t1.Permit.DateIssued.Value.Date <= DateTime.Parse(DateIssuedTo).Date) && t1.Permit.PermitApplicant.Name.ToLower().Contains(ApplicantName.ToLower()) || t1.Permit.AffidavitID.Value.Equals(AffidavitNumber) orderby t1.Permit.DateIssued descending select t1).ToList(); ApprovedPermits = new ObservableCollection <PermitModel>(filteredPermits.Distinct().ToList()); }