public IActionResult SearchEVisaMerchant([FromQuery] EVisaMerchantSearchModel model) { var response = _eVisaMerchantService.SearchEVisaMerchant(model); if (response != null) { return(Ok(response)); } return(BadRequest()); }
public IPagedList <EVisaMerchantViewModel> SearchEVisaMerchant(EVisaMerchantSearchModel model) { var searchString = !string.IsNullOrEmpty(model.SortString) ? model.SortString : $"{nameof(VisaMerchants.CreatedDate)} Desc"; var lstEvisaMerchant = new PagedList <EVisaMerchantViewModel>(); var query = _dbEvisaContext.VisaMerchants.AsNoTracking().Where(x => x.Deleted == false && string.IsNullOrEmpty(model.Country) || x.Country.Contains(model.Country) && string.IsNullOrEmpty(model.City) || x.City.Contains(model.City) && string.IsNullOrEmpty(model.State) || x.State.Contains(model.State)).Select(x => _mapper.Map <EVisaMerchantViewModel>(x)).OrderBy(searchString); if (query.Count() > 0) { lstEvisaMerchant = new PagedList <EVisaMerchantViewModel>(query, model.PageIndex, model.PageSize); } return(lstEvisaMerchant); }