/************ * BOOKINGS * ************/ public Booking CreateBooking(string hotelName, BookingConstraints constraints, string guestName) { var hotel = GetHotel(hotelName); if (hotel == null) { throw new ArgumentException("There exists no hotel with the given name."); } foreach (RoomDetails rd in hotel.GetFreeRooms(constraints.StartDate, constraints.EndDate)) { if (rd.SmokingAllowed.Equals(constraints.SmokingAllowed) && constraints.NbOfBeds <= rd.NbOfBeds && constraints.MaxPricePerNight >= rd.PricePerNight) { return(new Booking { Guest = guestName, StartDate = constraints.StartDate, EndDate = constraints.EndDate, RoomNb = rd.RoomNb, HotelName = hotel.Name, Price = calc.CalculatePrice(rd.PricePerNight, constraints.StartDate, constraints.EndDate) }); } } throw new BookingException("No room to satisfy the given booking constraints."); }
public ActionResult BookingConstraints(BookingConstraints bb) { IEnumerable <DoctorDetail> dd = m.GetAllDcotors(); List <DoctorDetail> docs = dd.Where(n => n.Specaility == bb.speciality.ToString() && n.IsAvailable == "yes").ToList(); return(View("DoctorAvailability", docs)); }
public ActionResult CreateBooking(string hotelName, BookingConstraints constraints, string guest) { try { Booking b = bk.CreateBooking(hotelName, constraints, guest); PlannedTrip trip = Session["trip"] as PlannedTrip ?? new PlannedTrip(); trip.TentativeBookings.Add(b); Session["trip"] = trip; return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError(String.Empty, e.Message); return(View()); } }