public IPagedList <CommonResourcesViewModel> GetAllCommonResourcesPaging(CommonResourcesSearchModel model) { string sortString = !string.IsNullOrEmpty(model.SortString) ? model.SortString : "ResourceKey ASC"; var result = (from value in _dbConfigContext.CommonResources.AsNoTracking() where (string.IsNullOrEmpty(model.ResourceKey) || value.ResourceKey.Contains(model.ResourceKey)) && (string.IsNullOrEmpty(model.ResourceValue) || value.ResourceValue.Contains(model.ResourceValue)) && (model.LanguageFid == null || value.LanguageFid == model.LanguageFid) select _mapper.Map <CommonResources, CommonResourcesViewModel>(value)).OrderBy(sortString).AsQueryable(); return(new PagedList <CommonResourcesViewModel>(result, model.PageIndex, model.PageSize)); }
public IActionResult SearchResources([FromQuery] CommonResourcesSearchModel model) { try { var result = _commonResourcesServices.GetAllCommonResourcesPaging(model); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.StackTrace.ToString())); } }