public async Task <UserDiarySearchModel> GetUserDiarys(UserDiarySearchModel model) { var url = CRMApiUri + "/UserDiary/GetUserDiarys?" + GetFilterString(model); var result = await GetOdataResultFromApi(url); var searchResultCount = 0; if (result.Count != null) { int.TryParse(result.Count.ToString(), out searchResultCount); } model.TotalRows = searchResultCount; model.UserDiarySearchResult.Clear(); try { model.UserDiarySearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <UserDiaryDto>(item.ToString()))); } catch (Exception e) { Console.WriteLine(e); throw; } return(model); }
private string GetFilterString(UserDiarySearchModel searchModel) { var filterString = string.Empty; if (searchModel != null) { if (!string.IsNullOrWhiteSpace(searchModel.FilterText)) { if (string.IsNullOrWhiteSpace(filterString)) { filterString = ODataFilterConstant.Filter + $"contains(Forename,'{searchModel.FilterText}') eq true"; } else { filterString += $" or contains(Forename,'{searchModel.FilterText}') eq true"; } filterString += $" or contains(Surname,'{searchModel.FilterText}') eq true"; } AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString); } return(filterString); }
public async Task <UserDiarySearchModel> GetUserDiarys(UserDiarySearchModel model) { return(await _userDiaryApiClient.GetUserDiarys(model)); }