Esempio n. 1
0
        public GetHorseAdListResultsDTO SearchHorses(HorseAdSearchViewModel searchViewModel)
        {
            SearchModelDao searchModelDao = UtilConverter.FromSearchModelToSearchModelDao(searchViewModel);

            var sortAfterValues = Enum.GetValues(typeof(SortAfterEnum));

            switch (searchModelDao.SortAfter)
            {
            case (int)SortAfterEnum.Age:
                searchModelDao.SortAfterString = SortAfterEnum.Age.ToString();
                break;

            case (int)SortAfterEnum.Height:
                searchModelDao.SortAfterString = SortAfterEnum.Height.ToString();
                break;

            case (int)SortAfterEnum.Price:
                searchModelDao.SortAfterString = SortAfterEnum.Price.ToString();
                break;

            case (int)SortAfterEnum.Views:
                searchModelDao.SortAfterString = SortAfterEnum.Views.ToString();
                break;

            default:
                searchModelDao.SortAfterString = SortAfterEnum.DatePosted.ToString();
                break;
            }

            if (searchModelDao.SortDirection != 1 && searchModelDao.SortDirection != 0)
            {
                searchModelDao.SortDirection = 1;
            }

            SearchHorseDao searchQuery = new SearchHorseDao(searchModelDao);

            var matchHorses = _iHorseAdDao.SearchAfter(searchQuery, searchViewModel.PageNumber);

            return(HorseAdConverter.ConvertHorseListResult(matchHorses));
        }
Esempio n. 2
0
        public GetHorseAdListResultsDTO GetAllForAdmin(int pageNumber)
        {
            var allUnvalidatedHorsePosts = _iHorseAdDao.GetAllForAdmin(pageNumber);

            return(HorseAdConverter.ConvertHorseListResult(allUnvalidatedHorsePosts));
        }