public ActionResult Add(Customer customer) { customer.HotelName = HotelName.GetHotelName(User.Identity.GetUserName()); ViewBag.Number = 0; if (customer.Date_from.CompareTo(customer.Date_to) == 1) { ViewBag.Message = "Invalid date! The starting date cannot be later than the ending date."; return(View("Add", customer)); } else { if (!CheckAndAdd.CheckDays(customer.Date_from, customer.Date_to, customer.Room, customer.HotelName)) { ViewBag.Message = "The chosen date is already resereved for this room."; return(View("Add", customer)); } else { if (!ModelState.IsValid) { return(View("Add", customer)); } else { db.Customer.Add(customer); db.SaveChanges(); ViewBag.Message = "Reservation has been added successfully!"; ViewBag.Number = 1; return(View("Add")); } } } }
// [Route] public ActionResult Manage(string options, string search) { string hotelName = HotelName.GetHotelName(User.Identity.GetUserName()); var all = db.Customer.Where(x => x.HotelName == hotelName).ToList(); if (options == "1") { all = db.Customer.Where(x => x.Name.StartsWith(search) && x.HotelName == hotelName || search == null).ToList(); } else if (options == "2") { all = db.Customer.Where(x => x.Surname.StartsWith(search) && x.HotelName == hotelName || search == null).ToList(); } else if (options == "3") { all = db.Customer.Where(x => x.Date_from.ToString() == search && x.HotelName == hotelName || search == null).ToList(); } else if (options == "4") { all = db.Customer.Where(x => x.Date_to.ToString() == search && x.HotelName == hotelName || search == null).ToList(); } else if (options == "5") { all = db.Customer.Where(x => x.Room.ToString() == search && x.HotelName == hotelName || search == null).ToList(); } ManageViewModel vm = new ManageViewModel() { Tuples = all }; return(View(vm)); }
/// <summary> /// calculates and returns the rents for different hotels /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="noOfDays">The no of days.</param> /// <returns></returns> /// <exception cref="HotelReservationException"> /// throws exception Hotel doesn't exist for invalid hotel name /// or /// throws exception Invalid Customer Type when wrong customer type is entered. /// </exception> public int HotelRentGenerator(HotelName name, CustomerType type, int regularDays, int weekendDays) { if (type.Equals(CustomerType.REGULAR)) { if (name.Equals(HotelName.Lakewood)) { regularRate = 110; weekendRate = 90; return(regularDays * regularRate + weekendDays * weekendRate); } if (name.Equals(HotelName.Bridgewood)) { regularRate = 150; weekendRate = 50; return(regularDays * regularRate + weekendDays * weekendRate); } if (name.Equals(HotelName.Ridgewood)) { regularRate = 220; weekendRate = 150; return(regularDays * regularRate + weekendDays * weekendRate); } else { throw new HotelReservationException(HotelReservationException.ExceptionType.NO_SUCH_HOTEL, "Hotel doesn't exist"); } } if (type.Equals(CustomerType.REWARD)) { if (name.Equals(HotelName.Lakewood)) { regularRate = 80; weekendRate = 80; return(regularDays * regularRate + weekendDays * weekendRate); } if (name.Equals(HotelName.Bridgewood)) { regularRate = 110; weekendRate = 50; return(regularDays * regularRate + weekendDays * weekendRate); } if (name.Equals(HotelName.Ridgewood)) { regularRate = 100; weekendRate = 40; return(regularDays * regularRate + weekendDays * weekendRate); } else { throw new HotelReservationException(HotelReservationException.ExceptionType.NO_SUCH_HOTEL, "Hotel doesn't exist"); } } else { throw new HotelReservationException(HotelReservationException.ExceptionType.NO_SUCH_CUSTOMER_TYPE, "Invalid Customer Type"); } }
public ActionResult Edit(int id) { var customer = db.Customer.Single(x => x.CustomerId == id); string hotelName = HotelName.GetHotelName(User.Identity.GetUserName()); if (customer.HotelName == hotelName) { return(View(customer)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Delete(int id) { string hotelName = HotelName.GetHotelName(User.Identity.GetUserName()); var customer = db.Customer.Single(x => x.CustomerId == id); if (customer.HotelName == hotelName) { HSSContext db = new HSSContext(); var x = db.Customer.First(u => u.CustomerId == id); db.Customer.Remove(x); db.SaveChanges(); return(View()); } else { return(RedirectToAction("Manage")); } }
public static async Task <HotelAvailability> GetAvailabilityForHotel(HotelName hotelName, DateTime startDate, DateTime endDate) { Dictionary <string, Object> roomsData = ReadRoomDataFromFile(hotelName); HotelAvailability hotelAvailability = new HotelAvailability(hotelName); List <DateTime> requestDates = CalculateRequestDates(startDate, endDate); foreach (DateTime requestDate in requestDates) { await AddAvailabilityAroundDate(hotelAvailability, requestDate, roomsData); } hotelAvailability.TrimDateRange(startDate, endDate); Console.WriteLine("\nEarliest available date for " + hotelName.Name + ": " + hotelAvailability.GetEarliestKnownDate().ToLongDateString()); Console.WriteLine("Latest available date for " + hotelName.Name + ": " + hotelAvailability.GetLatestKnownDate().ToLongDateString() + "\n"); Console.WriteLine("Total number of rooms gathered for " + hotelName.Name + ": " + hotelAvailability.RoomAvailabilities.Count); return(hotelAvailability); }
public HotelName BestRatedHotel(string checkInDate, string checkOutDate, CustomerType customerType) { /** this method helps us find the best rated hotel * checkin and checkout dates along with customer types are passed as parameters * */ HotelName hotelName = HotelName.LAKEWOOD; HotelData lakeWood = new HotelData(hotelName, customerType); double rateOfLakeWood = lakeWood.CostOfHotel(checkInDate, checkOutDate); hotelName = HotelName.BRIDGEWOOD; HotelData bridgeWood = new HotelData(hotelName, customerType); double rateOfBridgeWood = bridgeWood.CostOfHotel(checkInDate, checkOutDate); hotelName = HotelName.RIDGEWOOD; HotelData ridgeWood = new HotelData(hotelName, customerType); double rateOfRidgeWood = ridgeWood.CostOfHotel(checkInDate, checkOutDate); if (lakeWood.ratingOfHotel > bridgeWood.ratingOfHotel && lakeWood.ratingOfHotel > ridgeWood.ratingOfHotel) { hotelName = HotelName.LAKEWOOD; Console.WriteLine("Best rated hotel is: " + hotelName); Console.WriteLine("Rating of the hotel: " + lakeWood.ratingOfHotel); Console.WriteLine("Total Cost: $" + rateOfLakeWood); } if (bridgeWood.ratingOfHotel > lakeWood.ratingOfHotel && bridgeWood.ratingOfHotel > ridgeWood.ratingOfHotel) { hotelName = HotelName.BRIDGEWOOD; Console.WriteLine("Best rated hotel is: " + hotelName); Console.WriteLine("Rating of the hotel: " + bridgeWood.ratingOfHotel); Console.WriteLine("Total Cost: $" + rateOfBridgeWood); } if (ridgeWood.ratingOfHotel > bridgeWood.ratingOfHotel && ridgeWood.ratingOfHotel > bridgeWood.ratingOfHotel) { hotelName = HotelName.RIDGEWOOD; Console.WriteLine("Best rated hotel is: " + hotelName); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel); Console.WriteLine("Total Cost: $" + rateOfRidgeWood); } return(hotelName); }
private static Dictionary <string, Object> ReadRoomDataFromFile(HotelName hotelName) { string fileName = hotelName.Name + ".json"; Dictionary <string, Object> roomsData = new Dictionary <string, Object>(); string fileText; Assembly _assembly = Assembly.GetExecutingAssembly(); using (var streamReader = new StreamReader(_assembly.GetManifestResourceStream("Scraper.resources.resortData.BigWhite." + fileName))) { fileText = streamReader.ReadToEnd(); } Dictionary <string, dynamic> root = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(fileText); if (root.ContainsKey(PROPERTY_CODE_KEY)) { roomsData.Add(PROPERTY_CODE_KEY, root[PROPERTY_CODE_KEY].ToString()); } string roomNumberCode = root[ROOM_NUMBER_CODE_KEY]; string resortCode = root[RESORT_CODE_KEY]; roomsData.Add(ROOM_NUMBER_CODE_KEY, roomNumberCode); roomsData.Add(RESORT_CODE_KEY, resortCode); Dictionary <string, List <string> > roomNumberData = root[ROOM_NUMBERS_KEY].ToObject <Dictionary <string, List <string> > >(); List <string> fullRoomNumbers = new List <string>(); foreach (KeyValuePair <string, List <string> > property in roomNumberData) { foreach (string roomNumber in property.Value) { fullRoomNumbers.Add(property.Key + " - " + roomNumber); } } roomsData.Add(ROOM_NUMBERS_KEY, fullRoomNumbers); return(roomsData); }
public void DisplayListOfHotels(CustomerType customerType) { /** this method helps us display list of hotels along with details * customer type is passed as parameters * objects of enum are created which are passed along with customertype to the invoked constructor of HotelData class */ Console.WriteLine("\n"); Console.WriteLine("Displaying for {0} Customer type", customerType); Console.WriteLine("HOTEL NAME\tRATING\tWEEKDAY RATES\tWEEKEND RATES"); HotelName hotelName = HotelName.LAKEWOOD; HotelData lakeWood = new HotelData(hotelName, customerType); Console.WriteLine(hotelName + "\t" + lakeWood.ratingOfHotel + "\t\t$" + lakeWood.weekDayRateOfHotel + "\t\t$" + lakeWood.weekEndRateOfHotel); hotelName = HotelName.BRIDGEWOOD; HotelData bridgeWood = new HotelData(hotelName, customerType); Console.WriteLine(hotelName + "\t" + bridgeWood.ratingOfHotel + "\t\t$" + bridgeWood.weekDayRateOfHotel + "\t\t$" + bridgeWood.weekEndRateOfHotel); hotelName = HotelName.RIDGEWOOD; HotelData ridgeWood = new HotelData(hotelName, customerType); Console.WriteLine(hotelName + "\t" + ridgeWood.ratingOfHotel + "\t\t$" + ridgeWood.weekDayRateOfHotel + "\t\t$" + ridgeWood.weekEndRateOfHotel); }
public void OnEnteringOneWeekDayAndOneWeekEndDayForRewardCustomerShouldReturnBestRatedCheapestHotel() { HotelName hotelName = hotelOperations.BestRatedCheapestHotel("06/12/2020", "07/12/2020", CustomerType.REWARD); Assert.AreEqual(hotelName, HotelName.RIDGEWOOD); }
public static void SendEmail(string pathToExcelFolder, HotelName hotelName) { SendEmail(pathToExcelFolder, new List <HotelName> { { hotelName } }); }
public void OnEnteringTwoWeekDaysForRewardCustomersShouldReturnBestRatedCheapestHotels() { HotelName hotelName = hotelOperations.BestRatedCheapestHotel("07/12/2020", "08/12/2020", CustomerType.REWARD); Assert.AreEqual(hotelName, HotelName.LAKEWOOD); }
public int ratingOfHotel; // rating of hotels public HotelData(HotelName nameOfHotel, CustomerType customerType) { /* parameterized constructor * try-catch block checks for exception thrown by invalid hotel name */ this.nameOfHotel = nameOfHotel; try { /* checking name of hotels * inner try-catch block to handle exceptions for invalid customer type * assigning weekday and weekend rates based on customer type */ if (nameOfHotel.Equals(HotelName.LAKEWOOD)) { this.ratingOfHotel = 3; try { if (customerType.Equals(CustomerType.REGULAR)) { this.weekDayRateOfHotel = 110; this.weekEndRateOfHotel = 90; } if (customerType.Equals(CustomerType.REWARD)) { this.weekDayRateOfHotel = 80; this.weekEndRateOfHotel = 80; } } catch (HotelReservationException) { throw new HotelReservationException(HotelReservationException.ExceptionType.INVALID_CUSTOMER_TYPE, "Invalid Customer Type"); } } if (nameOfHotel.Equals(HotelName.BRIDGEWOOD)) { this.ratingOfHotel = 4; try { if (customerType.Equals(CustomerType.REGULAR)) { this.weekDayRateOfHotel = 150; this.weekEndRateOfHotel = 50; } if (customerType.Equals(CustomerType.REWARD)) { this.weekDayRateOfHotel = 110; this.weekEndRateOfHotel = 50; } } catch (HotelReservationException) { throw new HotelReservationException(HotelReservationException.ExceptionType.INVALID_CUSTOMER_TYPE, "Invalid Customer Type"); } } if (nameOfHotel.Equals(HotelName.RIDGEWOOD)) { this.ratingOfHotel = 5; try { if (customerType.Equals(CustomerType.REGULAR)) { this.weekDayRateOfHotel = 220; this.weekEndRateOfHotel = 150; } if (customerType.Equals(CustomerType.REWARD)) { this.weekDayRateOfHotel = 100; this.weekEndRateOfHotel = 40; } } catch (HotelReservationException) { throw new HotelReservationException(HotelReservationException.ExceptionType.INVALID_CUSTOMER_TYPE, "Invalid Customer Type"); } } } catch (HotelReservationException) { throw new HotelReservationException(HotelReservationException.ExceptionType.INVALID_HOTEL_NAME, "Invalid Name of Hotel"); } }
public HotelAvailability(HotelName name) { Name = name; RoomAvailabilities = new Dictionary <string, RoomAvailability>(); }
public void OnEnteringDateRangeAndRewardCustomerShouldReturnBestRatedHotel() { HotelName hotelName = hotelOperations.BestRatedHotel("30/11/2020", "01/12/2020", CustomerType.REWARD); Assert.AreEqual(hotelName, HotelName.RIDGEWOOD); }
public HotelName BestRatedCheapestHotel(string checkInDate, string checkOutDate, CustomerType customerType) { /* this method finds best rated cheapest hotels * check-in and check-out dates along with customer types are passed as parameters * first the cheapest hotels are found * then details of the hotel having highest rating is printed */ HotelName hotelName = HotelName.LAKEWOOD; HotelData lakeWood = new HotelData(hotelName, customerType); double rateOfLakeWood = lakeWood.CostOfHotel(checkInDate, checkOutDate); hotelName = HotelName.BRIDGEWOOD; HotelData bridgeWood = new HotelData(hotelName, customerType); double rateOfBridgeWood = bridgeWood.CostOfHotel(checkInDate, checkOutDate); hotelName = HotelName.RIDGEWOOD; HotelData ridgeWood = new HotelData(hotelName, customerType); double rateOfRidgeWood = ridgeWood.CostOfHotel(checkInDate, checkOutDate); if (rateOfLakeWood < rateOfBridgeWood && rateOfLakeWood < rateOfRidgeWood) { hotelName = HotelName.LAKEWOOD; Console.WriteLine("Cheapest Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + lakeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfLakeWood); } if (rateOfBridgeWood < rateOfLakeWood && rateOfBridgeWood < rateOfRidgeWood) { hotelName = HotelName.BRIDGEWOOD; Console.WriteLine("Cheapest Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + bridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfBridgeWood); } if (rateOfRidgeWood < rateOfLakeWood && rateOfRidgeWood < rateOfBridgeWood) { hotelName = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfRidgeWood); } if (rateOfLakeWood == rateOfBridgeWood && rateOfLakeWood < rateOfRidgeWood) { hotelName = HotelName.BRIDGEWOOD; Console.WriteLine("Cheapest and Best Rated Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + bridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfBridgeWood); } if (rateOfLakeWood == rateOfRidgeWood && rateOfLakeWood < rateOfBridgeWood) { hotelName = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfRidgeWood); } if (rateOfBridgeWood == rateOfRidgeWood && rateOfBridgeWood < rateOfLakeWood) { hotelName = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfRidgeWood); } if (rateOfLakeWood == rateOfBridgeWood && rateOfLakeWood == rateOfRidgeWood) { hotelName = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfRidgeWood); } return(hotelName); }
public HotelAvailability(HotelName name, Dictionary <string, RoomAvailability> roomAvailabilities) { Name = name; RoomAvailabilities = roomAvailabilities; }
public int FindCheapestHotel(string checkInDate, string checkOutDate, CustomerType customerType) { /*this method finds out the cheapest hotel * checkin and checkout dates along with customer type are passed as parameters * objects of enum HotelName are created which are passed as parameters to the method finding hotel cost * finally they are compared */ HotelName hotelName1; HotelName hotelName2; HotelName hotelName3; int i = 0; HotelName hotelName = HotelName.LAKEWOOD; HotelData lakeWood = new HotelData(hotelName, customerType); double rateOfLakeWood = lakeWood.CostOfHotel(checkInDate, checkOutDate); hotelName = HotelName.BRIDGEWOOD; HotelData bridgeWood = new HotelData(hotelName, customerType); double rateOfBridgeWood = bridgeWood.CostOfHotel(checkInDate, checkOutDate); hotelName = HotelName.RIDGEWOOD; HotelData ridgeWood = new HotelData(hotelName, customerType); double rateOfRidgeWood = ridgeWood.CostOfHotel(checkInDate, checkOutDate); if (rateOfLakeWood < rateOfBridgeWood && rateOfLakeWood < rateOfRidgeWood) { hotelName = HotelName.LAKEWOOD; Console.WriteLine("Cheapest Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + lakeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfLakeWood); i++; } if (rateOfBridgeWood < rateOfLakeWood && rateOfBridgeWood < rateOfRidgeWood) { hotelName = HotelName.BRIDGEWOOD; Console.WriteLine("Cheapest Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + bridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfBridgeWood); i++; } if (rateOfRidgeWood < rateOfLakeWood && rateOfRidgeWood < rateOfBridgeWood) { hotelName = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotel for the entered date range: " + hotelName); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfRidgeWood); i++; } if (rateOfLakeWood == rateOfBridgeWood && rateOfLakeWood < rateOfRidgeWood) { hotelName1 = HotelName.LAKEWOOD; hotelName2 = HotelName.BRIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName1 + "\t" + hotelName2); Console.WriteLine("Rating of the hotel: " + lakeWood.ratingOfHotel + "\t" + bridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfLakeWood + "\t$" + rateOfBridgeWood); i += 2; } if (rateOfLakeWood == rateOfRidgeWood && rateOfLakeWood < rateOfBridgeWood) { hotelName1 = HotelName.LAKEWOOD; hotelName2 = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName1 + "\t" + hotelName2); Console.WriteLine("Rating of the hotel: " + lakeWood.ratingOfHotel + "\t" + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfLakeWood + "\t$" + rateOfRidgeWood); i += 2; } if (rateOfBridgeWood == rateOfRidgeWood && rateOfBridgeWood < rateOfLakeWood) { hotelName1 = HotelName.RIDGEWOOD; hotelName2 = HotelName.BRIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName1 + "\t" + hotelName2); Console.WriteLine("Rating of the hotel: " + ridgeWood.ratingOfHotel + "\t" + bridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfRidgeWood + "\t$" + rateOfBridgeWood); i += 2; } if (rateOfLakeWood == rateOfBridgeWood && rateOfLakeWood == rateOfRidgeWood) { hotelName1 = HotelName.LAKEWOOD; hotelName2 = HotelName.BRIDGEWOOD; hotelName3 = HotelName.RIDGEWOOD; Console.WriteLine("Cheapest Hotels for the entered date range: " + hotelName1 + "\t" + hotelName2 + "\t" + hotelName3); Console.WriteLine("Rating of the hotel: " + lakeWood.ratingOfHotel + "\t" + bridgeWood.ratingOfHotel + "\t" + ridgeWood.ratingOfHotel); Console.WriteLine("Total cost for the given date range: $" + rateOfLakeWood + "\t$" + rateOfBridgeWood + "\t$" + rateOfRidgeWood); i += 3; } return(i); }
public void OnEnteringTwoWeekEndDaysForRegularCustomersShouldReturnBestRatedCheapestHotels() { HotelName hotelName = hotelOperations.BestRatedCheapestHotel("05/12/2020", "06/12/2020", CustomerType.REGULAR); Assert.AreEqual(hotelName, HotelName.BRIDGEWOOD); }