public ActionResult FullPropertyResult(string propertyID) { #region FullPropertyResult_CatchNoValue int aTest; if (propertyID == null || propertyID == "" || !(Int32.TryParse(propertyID, out aTest))) { return(Redirect("~/Home/SearchProperties")); } #endregion Property theProperty = Property.GetPropertyByID(Int32.Parse(propertyID)); ViewBag.FullPropertyResultProperty = theProperty; PRCImageCollection ImageCollection = new PRCImageCollection(Server, theProperty.LegacyReference); ViewBag.ImageCollection = ImageCollection; //booking calendar population BookingCalendar TestBookingCalendar = new BookingCalendar(Int32.Parse(propertyID)); TestBookingCalendar.GetAllBookingDatesAndAddToThisCalendar(); ViewBag.BookingCalDates = TestBookingCalendar; //Comments List <BootstrapVillas.Models.Comment> theComments = BootstrapVillas.Models.Comment.GetComments(theProperty); //Comment replies ViewBag.Keywords = "portugal rental cottages, silver coast portugal, cheap holidays in portugal, cheap all inclusive holidays to portugal,holiday villa portugal"; ViewBag.IdentifyPage = "FullPropertyResult"; ViewBag.Title = "Here is the information, photos, facilities and features for this Villa, Townhouse, Apartment or Hotel holiday rentals in Portugal. A selective but extensive range of quality holiday properties to choose from, where you can visit Candieeros National Park and take in the sights of Tomar and Fatima on one of our sightseeing tours or wine tours should you wish. Holiday Villas in Olho Marinho, Reguengo Grande, Salir de Matos and Avarela all with luxury extras like Swimming Pools, Pool Heating, Mid Vacation Cleaning and Internet use (please check property). Visit the Loridos Vineyards and stay in one of our classic Portugal Rental Cottages!"; return(View()); }
public ActionResult BookingCalendar(long propertyID) { var calendar = new BookingCalendar(propertyID); calendar.GetAllBookingDatesAndAddToThisCalendar(); return(View(calendar)); }
/// <summary> /// The booking calendar. /// </summary> /// <param name="hotel"> /// The hotel. /// </param> /// <param name="date"> /// The date. /// </param> /// <returns> /// The <see cref="List{BookingCalendar}"/>. /// </returns> /// <exception cref="Exception"> /// Throws exception when refresh occurs. /// </exception> public List <BookingCalendar> BookingCalendar(Hotel hotel, DateTime date) { this.bookingController = new BookingController(); this.roomController = new RoomController(); this.calendarList = new List <BookingCalendar>(); IList <Booking> bookings; IList <Room> rooms; try { bookings = hotel != null?this.bookingController.RefreshEntities().Where(x => x.Room.HotelId == hotel.Id).ToList() : this.bookingController.RefreshEntities(); rooms = hotel != null?this.roomController.RefreshEntities().Where(x => x.HotelId == hotel.Id).ToList() : this.roomController.RefreshEntities(); } catch (Exception) { throw new Exception(); } foreach (var availableRoom in rooms) { var calendarEntry = new BookingCalendar(); var properties = typeof(BookingCalendar).GetProperties().Where(x => x.Name.StartsWith("Day")); foreach (var property in properties) { var dateString = $"{property.Name.Substring(3)}/{date.Month}/{date.Year}"; DateTime parsedDate; if (!DateTime.TryParse(dateString, out parsedDate)) { property.SetValue(calendarEntry, AvailableStatus.NotExistingDay); continue; } var currentBooking = bookings.SingleOrDefault( x => x.Room.Id == availableRoom.Id && x.From <= parsedDate && x.To >= parsedDate); if (currentBooking == null || currentBooking.Status == Status.Cancelled) { continue; } switch (currentBooking.Status) { case Status.New: property.SetValue(calendarEntry, AvailableStatus.NotAvailable); break; case Status.Active: property.SetValue(calendarEntry, AvailableStatus.NotAvailableOccupied); break; case Status.Billed: property.SetValue(calendarEntry, AvailableStatus.NotAvailableBilled); break; } } calendarEntry.Hotel = availableRoom.HotelName; calendarEntry.Room = availableRoom.Code; this.calendarList.Add(calendarEntry); } return(this.calendarList); }