コード例 #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TotalReviewsLabel.Text = string.Format(Constant.TotalReviewsText, 0, "All Reviews");

                int hotelId = 0;
                if (Page.RouteData.Values["hotelId"] != null)
                {
                    int.TryParse(Page.RouteData.Values["hotelId"].ToString(), out hotelId);
                }

                var hotels = _hotelRepository.GetAll()
                             .Where(h => h.IsActive && !h.IsDelete && h.IsPublished)
                             .OrderBy(h => h.HotelName)
                             .ToList();

                var selectedHotel = hotels.FirstOrDefault(h => h.HotelId == hotelId);

                var reviews = selectedHotel != null
                    ? _surveyRepository.GetByHotelId(hotelId)
                    : _surveyRepository.GetAllReviews();

                ReviewsRpt.DataSource = reviews;
                ReviewsRpt.DataBind();

                string hotelSelectedString = selectedHotel != null
                    ? string.Format(Constant.TotalReviewsText, reviews.Count(),
                                    string.Format("{0} - {1}", selectedHotel.HotelName, selectedHotel.City))
                    : string.Format(Constant.TotalReviewsText, reviews.Count(), "All Hotels");

                AddAllHotels();

                hotels.ForEach(hotel =>
                {
                    var liTag = new HtmlGenericControl("li");
                    var link  = new HtmlAnchor
                    {
                        HRef      = "#",
                        InnerText = string.Format("{0} - {1}", hotel.HotelName, hotel.City)
                    };
                    link.Attributes["data-href"] = Helper.ResolveRelativeToAbsoluteUrl(Request.Url, string.Format("/reviews/{0}", hotel.HotelId));
                    liTag.Controls.Add(link);

                    HotelDropdown.Controls.Add(liTag);
                });

                TotalReviewsLabel.Text = hotelSelectedString;
                HotelLabel.Text        = selectedHotel != null?string.Format("{0} - {1}", selectedHotel.HotelName, selectedHotel.City) : "All Hotels";

                FilterButton.NavigateUrl = selectedHotel != null
                    ? Helper.ResolveRelativeToAbsoluteUrl(Request.Url,
                                                          string.Format("/reviews/{0}", selectedHotel.HotelId))
                    : Helper.ResolveRelativeToAbsoluteUrl(Request.Url, "/reviews");
            }
        }
コード例 #2
0
        public IEnumerable <Hotel> GetAll()
        {
            var hoteles = new List <Hotel>();

            hoteles.Add(new Hotel {
                Id = 0, Nombre = "- No Especificado -"
            });

            var repository = new HotelRepository();

            repository.GetAll().ToList().ForEach(hoteles.Add);

            return(hoteles);
        }
コード例 #3
0
        public string FindTheCheapestHotel(IHotelSearchCriteria hotelSearchCriteria)
        {
            Hotel cheapestHotel = null;

            foreach (var hotel in HotelRepository.GetAll())
            {
                if (cheapestHotel == null || hotel.IsCheaperThan(cheapestHotel, hotelSearchCriteria))
                {
                    cheapestHotel = hotel;
                }
            }

            return(cheapestHotel.Name);
        }
コード例 #4
0
        public IEnumerable <Hotel> GetAll(string nombre, int?estrellas, int?paisId, int?ciudadId)
        {
            var hoteles = new List <Hotel>();

            hoteles.Add(new Hotel {
                Id = 0, Nombre = "- No Especificado -"
            });

            var repository = new HotelRepository();

            repository.GetAll(nombre, estrellas, paisId, ciudadId).ToList().ForEach(hoteles.Add);

            return(hoteles);
        }
コード例 #5
0
        public IActionResult GetAll()
        {
            var hotels = new List <Hotel>();

            try
            {
                hotels = hotelRepository.GetAll().ToList();
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }

            hotels.ForEach(h => h.Region.Hotels = null);

            return(Ok(hotels));
        }
コード例 #6
0
 public IEnumerable <Hotel> Get()
 {
     return(HotelRepository.GetAll());
 }
コード例 #7
0
        // GET: Hotel
        public ActionResult Index()
        {
            var hotels = hotelRepository.GetAll();

            return(View(hotels));
        }
コード例 #8
0
ファイル: HotelBusiness.cs プロジェクト: Adekah/HotelGuide
        public List <HotelsViewModel> GetHotels()
        {
            HotelRepository repository = new HotelRepository();

            return(repository.GetAll());
        }