public static GetHorseAdListResultsDTO ConvertHorseListResult(GetHorseAdListResults result) { var horseAdListResult = new GetHorseAdListResultsDTO() { TotalCount = result.TotalCount, HorseAdList = result.HorseAdList.Select(HorseAdConverter.FromHorseAdToHorseAdListModel) }; return(horseAdListResult); }
public GetHorseAdListResults GetAllForAdmin(int pageNumber) { var skipNumber = GetNumberToSkip(pageNumber); var horseAds = _ctx.HorseAds.Where(e => !e.IsValidated); var results = new GetHorseAdListResults() { TotalCount = horseAds.Count(), HorseAdList = horseAds.OrderByDescending(e => e.DatePosted).Skip(skipNumber).ToList().Take(ApplicationConstants.AdsPerPage) }; return(results); }
public GetHorseAdListResults SearchAfter(SearchHorseDao searchQuery, int pageNumber) { var skipNumber = GetNumberToSkip(pageNumber); var searchPredicate = searchQuery.GetSearchPredicate(); var orderProperty = searchQuery.GetOrderProperty(); var isAscendingSortOrder = searchQuery.IsAscendingSortOrder(); var horseAds = _ctx.HorseAds.AsQueryable().AsExpandable().Where(searchPredicate); var results = new GetHorseAdListResults() { TotalCount = horseAds.Count(), HorseAdList = isAscendingSortOrder ? horseAds.AsEnumerable().OrderBy(x => orderProperty.GetValue(x, null)).Skip(skipNumber).Take(ApplicationConstants.AdsPerPage).ToList() : horseAds.AsEnumerable().OrderByDescending(x => orderProperty.GetValue(x, null)).Skip(skipNumber).Take(ApplicationConstants.AdsPerPage).ToList() }; return(results); }