コード例 #1
0
        public HorseAdDTO GetById(int id)
        {
            var horseAd = _iHorseAdDao.GetById(id);

            CheckIfHorseAdExists(horseAd);

            return(HorseAdConverter.FromHorseAdToHorseAdDTO(horseAd));
        }
コード例 #2
0
        public async Task Add(HorseAdDTO horseAdDTO, string userId)
        {
            ValidateHorseAd(horseAdDTO);

            var horseAd = HorseAdConverter.FromHorseAdDTOToHorseAd(horseAdDTO, userId);

            await _iHorseAdDao.AddHorse(horseAd);

            await SendEmailToAdmin();
        }
コード例 #3
0
        private HorseAd UpdateHorseAd(HorseAd horseAd, HorseAdDTO horseAdDTO)
        {
            horseAd.HorseName        = horseAdDTO.HorseName;
            horseAd.HorseAbilitesIds = horseAdDTO.AbilityIds;
            horseAd.Price            = !string.IsNullOrEmpty(horseAdDTO.Price) ? Convert.ToDecimal(horseAdDTO.Price) : 0M;
            horseAd.PriceRangeId     = horseAdDTO.PriceRangeId;
            horseAd.Breed            = horseAdDTO.Breed;
            horseAd.Age         = horseAdDTO.Age;
            horseAd.Description = horseAdDTO.Description;
            horseAd.Gender      = horseAdDTO.Gender;
            horseAd.HaveCompetionalExperience = horseAdDTO.HaveCompetionalExperience;
            horseAd.HaveXRays           = horseAdDTO.HaveXRays;
            horseAd.RecommendedRiderIds = horseAdDTO.RecomendedRidersIds;
            horseAd.IsSponsorized       = horseAdDTO.IsSponsorized;
            horseAd.VideoLink           = horseAdDTO.VideoLink;
            horseAd.Title  = HorseAdConverter.SetAdTitle(horseAdDTO);
            horseAd.Height = horseAdDTO.HeightInCm;

            horseAd.Address.City    = horseAdDTO.Address.City;
            horseAd.Address.Country = horseAdDTO.Address.Country;
            horseAd.Address.Street  = horseAdDTO.Address.Street;

            if (horseAd.Pedigree != null)
            {
                horseAd.Pedigree.Father               = horseAdDTO.Pedigree.Father;
                horseAd.Pedigree.Father_Father        = horseAdDTO.Pedigree.Father_Father;
                horseAd.Pedigree.Father_Mother        = horseAdDTO.Pedigree.Father_Mother;
                horseAd.Pedigree.Father_Father_Father = horseAdDTO.Pedigree.Father_Father_Father;
                horseAd.Pedigree.Father_Father_Mother = horseAdDTO.Pedigree.Father_Father_Mother;
                horseAd.Pedigree.Father_Mother_Father = horseAdDTO.Pedigree.Father_Mother_Father;
                horseAd.Pedigree.Father_Mother_Mother = horseAdDTO.Pedigree.Father_Mother_Mother;
                horseAd.Pedigree.Mother               = horseAdDTO.Pedigree.Mother;
                horseAd.Pedigree.Mother_Father        = horseAdDTO.Pedigree.Mother_Father;
                horseAd.Pedigree.Mother_Mother        = horseAdDTO.Pedigree.Mother_Mother;
                horseAd.Pedigree.Mother_Father_Father = horseAdDTO.Pedigree.Mother_Father_Father;
                horseAd.Pedigree.Mother_Father_Mother = horseAdDTO.Pedigree.Mother_Father_Mother;
                horseAd.Pedigree.Mother_Mother_Father = horseAdDTO.Pedigree.Mother_Mother_Father;
                horseAd.Pedigree.Mother_Mother_Mother = horseAdDTO.Pedigree.Mother_Mother_Mother;
            }
            else
            {
                horseAd.Pedigree = HorseAdConverter.FromPedigreeDTOToPedigree(horseAdDTO.Pedigree);
            }

            return(horseAd);
        }
コード例 #4
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));
        }
コード例 #5
0
        public GetHorseAdListResultsDTO GetAllForAdmin(int pageNumber)
        {
            var allUnvalidatedHorsePosts = _iHorseAdDao.GetAllForAdmin(pageNumber);

            return(HorseAdConverter.ConvertHorseListResult(allUnvalidatedHorsePosts));
        }