public async Task <List <Investor> > FindInvestor(SearchInvestorDto searchInvestorDto) { List <Investor> investor = null; try { if (searchInvestorDto.Tin != null && searchInvestorDto.FirstNameEng != null && searchInvestorDto.FatherNameEng != null && searchInvestorDto.GrandNameEng != null) { investor = await Context.Investors. Where(m => EF.Functions.Like(m.Tin, searchInvestorDto.Tin + "%") && EF.Functions.Like(m.FirstNameEng, searchInvestorDto.FirstNameEng + "%") && EF.Functions.Like(m.FatherNameEng, searchInvestorDto.FatherNameEng + "%") && EF.Functions.Like(m.GrandNameEng, searchInvestorDto.GrandNameEng + "%")) .ToListAsync(); } else if (searchInvestorDto.FirstNameEng != null && searchInvestorDto.FatherNameEng != null && searchInvestorDto.GrandNameEng != null) { investor = await Context.Investors. Where(m => EF.Functions.Like(m.FirstNameEng, searchInvestorDto.FirstNameEng + "%") && EF.Functions.Like(m.FatherNameEng, searchInvestorDto.FatherNameEng + "%") && EF.Functions.Like(m.GrandNameEng, searchInvestorDto.GrandNameEng + "%")) .ToListAsync(); } else if (searchInvestorDto.FirstNameEng != null && searchInvestorDto.FatherNameEng != null) { investor = await Context.Investors. Where(m => EF.Functions.Like(m.FirstNameEng, searchInvestorDto.FirstNameEng + "%") && EF.Functions.Like(m.FatherNameEng, searchInvestorDto.FatherNameEng + "%")) .ToListAsync(); } else if (searchInvestorDto.FirstNameEng != null) { investor = await Context.Investors. Where(m => EF.Functions.Like(m.FirstNameEng, searchInvestorDto.FirstNameEng + "%")) .ToListAsync(); } else if (searchInvestorDto.Tin != null) { investor = await Context.Investors. Where(m => EF.Functions.Like(m.Tin, searchInvestorDto.Tin + "%")) .ToListAsync(); } else { investor = await Context.Investors .ToListAsync(); } //context.Customers.Where(c => EF.Functions.Like(c.Name, "a%")); } catch (InvalidOperationException) { SetError("Couldn't load Investor - invalid Investor id specified."); return(null); } catch (Exception ex) { SetError(ex); } return(investor); }
public async Task <IEnumerable <Investor> > GetSearchedInvestor([FromBody] SearchInvestorDto searchInvestorDto) { return(await InvestorRepo.FindInvestor(searchInvestorDto)); }