Exemple #1
0
        public ICollection <LodgingReview> GetAllReviews(int id, int page, int resultsPerPage)
        {
            if (!LodgingRepository.Exists(l => l.Id == id))
            {
                throw new NotFoundException("Lodging");
            }

            var reviews = LodgingReviewRepository.GetAllWithPagination(
                x => x.Booking.Lodging.Id == id,
                "Booking,Booking.Tourist", page, resultsPerPage);

            return(reviews);
        }
Exemple #2
0
        public Lodging Create(Lodging lodging)
        {
            var touristSpot = TouristSpotRepository.Get(lodging.TouristSpot.Id);

            if (touristSpot == null)
            {
                throw new NotFoundException("TouristSpot");
            }

            if (LodgingRepository.Exists(x => x.Address == lodging.Address && x.IsDeleted == false))
            {
                throw new NotUniqueException("Address");
            }

            lodging.TouristSpot = touristSpot;
            LodgingRepository.Add(lodging);
            LodgingRepository.Save();

            return(LodgingRepository.GetFirst(x => x.Id == lodging.Id, "TouristSpot,Images"));
        }