Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public async Task <UserDiarySearchModel> GetUserDiarys(UserDiarySearchModel model)
 {
     return(await _userDiaryApiClient.GetUserDiarys(model));
 }