public decimal CalculateReservationCost() { Total = 0M; string start = CheckInDate.Substring(8, 2); string end = CheckOutDate.Substring(8, 2); int x = Int32.Parse(start); int y = Int32.Parse(end); int count = y - x; if (count > 0) { foreach (var r in Rooms) { Total += r.DailyRate; } return(Total * count); } return(Total); }
public async Task LateCheckOutWithExceededTimeTest() { var tokens = new Dictionary <string, object> { { "Time", HotelService.LateTime.ToString(ReservationData.TimeFormat) }, { "Date", CheckInDate.AddDays(HotelService.StayDays).ToString(ReservationData.DateFormat) } }; await this.GetTestFlow() .Send(StartActivity) .AssertReply(AssertContains(MainResponses.WelcomeMessage)) .AssertReply(AssertContains(MainResponses.FirstPromptMessage)) .Send(LateCheckOutUtterances.LateCheckOutWithExceededTime) .AssertReply(AssertContains(LateCheckOutResponses.CheckAvailability)) .AssertReply(AssertStartsWith(LateCheckOutResponses.MoveCheckOutPrompt, tokens)) .Send(NonLuisUtterances.Yes) .AssertReply(AssertContains(LateCheckOutResponses.MoveCheckOutSuccess, tokens, CardStrings.ReservationDetails)) .AssertReply(ActionEndMessage()) .StartTestAsync(); }
public async Task LateCheckOutAndCancelTest() { var tokens = new Dictionary <string, object> { { "Time", HotelService.LateTime.ToString(ReservationData.TimeFormat) }, { "Date", CheckInDate.AddDays(HotelService.StayDays).ToString(ReservationData.DateFormat) } }; await this.GetTestFlow() .Send(StartActivity) .AssertReply(AssertContains(MainResponses.WelcomeMessage)) .AssertReply(AssertContains(MainResponses.FirstPromptMessage)) .Send(LateCheckOutUtterances.LateCheckOut) .AssertReply(AssertContains(LateCheckOutResponses.CheckAvailability)) .AssertReply(AssertStartsWith(LateCheckOutResponses.MoveCheckOutPrompt, tokens)) .Send(GeneralTestUtterances.Cancel) .AssertReply(AssertContains(MainResponses.CancelMessage)) .AssertReply(AssertContains(MainResponses.FirstPromptMessage)) .StartTestAsync(); }
public override int GetHashCode() { int hash = 1; if (JWToken.Length != 0) { hash ^= JWToken.GetHashCode(); } if (reservation_ != null) { hash ^= Reservation.GetHashCode(); } if (checkInDate_ != null) { hash ^= CheckInDate.GetHashCode(); } if (roomId_ != null) { hash ^= RoomId.GetHashCode(); } if (guestId_ != null) { hash ^= GuestId.GetHashCode(); } if (averageRate_ != null) { hash ^= AverageRate.GetHashCode(); } if (ReservationBookingNumber.Length != 0) { hash ^= ReservationBookingNumber.GetHashCode(); } if (KeepGuaranteeRequested != false) { hash ^= KeepGuaranteeRequested.GetHashCode(); } return(hash); }
public override string ToString() { return($"Reservation for:{ClientId} at Hotel:{HotelName} (id:{HotelId}), RoomNumber:{RoomNumber} for check-in date:{CheckInDate.ToString("d")} and check-out date:{CheckOutDate.ToString("d")}"); }
public void CalculatePrice() { int checkInSeasson, checkOutSeasson; //if Price[i] gets addressed PropertyChanged is not working. Why? Setter is not invoked that way? ///priceArray[0] - room price out of the seasson ///priceArray[1] - room price in low seasson ///priceArray[2] - room price in high seasson ///priceArray[3] - total item price decimal[] priceArray = new decimal[4]; DateTime date0 = new DateTime(CheckInDate.Year, Settings.seassons[0].month, Settings.seassons[0].day); DateTime date1 = new DateTime(CheckInDate.Year, Settings.seassons[1].month, Settings.seassons[1].day); DateTime date2 = new DateTime(CheckInDate.Year, Settings.seassons[2].month, Settings.seassons[2].day); DateTime date3 = new DateTime(CheckInDate.Year, Settings.seassons[3].month, Settings.seassons[3].day); ///Determine in which tourist seassons are Check-In and Check-Out dates ///No need to validate the dates since UI does that if (CheckInDate.CompareTo(date0) < 0) { checkInSeasson = 0; } else if (CheckInDate.CompareTo(date1) < 0) { checkInSeasson = 1; } else if (CheckInDate.CompareTo(date2) < 0) { checkInSeasson = 2; } else if (CheckInDate.CompareTo(date3) < 0) { checkInSeasson = 3; } else { checkInSeasson = 0; } if (CheckOutDate.CompareTo(date0.AddDays(1)) < 0) { checkOutSeasson = 0; } else if (CheckOutDate.CompareTo(date1.AddDays(1)) < 0) { checkOutSeasson = 1; } else if (CheckOutDate.CompareTo(date2.AddDays(1)) < 0) { checkOutSeasson = 2; } else if (CheckOutDate.CompareTo(date3.AddDays(1)) < 0) { checkOutSeasson = 3; } else { checkOutSeasson = 0; } if (checkInSeasson == checkOutSeasson) { coveredSeassons = 1; Days[checkInSeasson] = (int)(Math.Round((CheckOutDate - CheckInDate).TotalHours) / 24); switch (checkInSeasson) { case 0: priceArray[checkInSeasson] = Days[checkInSeasson] * Settings.room[this.Name].Out; break; case 1: priceArray[checkInSeasson] = Days[checkInSeasson] * Settings.room[this.Name].Low; break; case 2: priceArray[checkInSeasson] = Days[checkInSeasson] * Settings.room[this.Name].High; break; case 3: priceArray[1] = Days[1] * Settings.room[this.Name].Low; break; } } else if (checkInSeasson == 0 && checkOutSeasson == 1) { coveredSeassons = 2; Days[0] = (int)(Math.Round((date0 - CheckInDate).TotalHours) / 24); priceArray[0] = Days[0] * Settings.room[this.Name].Out; Days[1] = (int)(Math.Round((CheckOutDate - date0).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; } else if (checkInSeasson == 1 && checkOutSeasson == 2) { coveredSeassons = 2; Days[1] = (int)(Math.Round((date1 - CheckInDate).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; Days[2] = (int)(Math.Round((CheckOutDate - date1).TotalHours) / 24); priceArray[2] = Days[2] * Settings.room[this.Name].High; } else if (checkInSeasson == 2 && checkOutSeasson == 3) { coveredSeassons = 2; Days[2] = (int)(Math.Round((date2 - CheckInDate).TotalHours) / 24); priceArray[2] = Days[2] * Settings.room[this.Name].High; Days[1] = (int)(Math.Round((CheckOutDate - date2).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; } else if (checkInSeasson == 3 && checkOutSeasson == 0) { coveredSeassons = 2; Days[1] = (int)(Math.Round((date3 - CheckInDate).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; Days[0] = (int)(Math.Round((CheckOutDate - date3).TotalHours) / 24); priceArray[0] = Days[0] * Settings.room[this.Name].Out; } else if (checkInSeasson == 0 && checkOutSeasson == 2) { coveredSeassons = 3; Days[0] = (int)(Math.Round((CheckInDate - date0).TotalHours) / 24); priceArray[0] = Days[0] * Settings.room[this.Name].Out; Days[1] = (int)(Math.Round((date1 - date0).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; Days[2] = (int)(Math.Round((CheckOutDate - date1).TotalHours) / 24); priceArray[2] = Days[2] * Settings.room[this.Name].High; } else if (checkInSeasson == 1 && checkOutSeasson == 3) { coveredSeassons = 2; Days[1] = (int)(Math.Round((date1 - CheckInDate).TotalHours) / 24); Days[2] = (int)(Math.Round((date2 - date1).TotalHours) / 24); priceArray[2] = Days[2] * Settings.room[this.Name].High; Days[1] += (int)(Math.Round((CheckOutDate - date2).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; } else if (checkInSeasson == 2 && checkOutSeasson == 0) { coveredSeassons = 3; Days[2] = (int)(Math.Round((date2 - CheckInDate).TotalHours) / 24); priceArray[2] = Days[2] * Settings.room[this.Name].High; Days[1] = (int)(Math.Round((date3 - date2).TotalHours) / 24); priceArray[1] = Days[1] * Settings.room[this.Name].Low; Days[0] = (int)(Math.Round((CheckOutDate - date3).TotalHours) / 24); priceArray[0] = Days[0] * Settings.room[this.Name].Out; } priceArray[3] = priceArray[0] + priceArray[1] + priceArray[2]; Array.Copy(priceArray, CleanPrice, priceArray.Length); if (BedsBig > 0) { priceArray[0] += BedsBig * Days[0] * Settings.bedPrices[this.Name].bigOut; priceArray[1] += BedsBig * Days[1] * Settings.bedPrices[this.Name].bigLow; priceArray[2] += BedsBig * Days[2] * Settings.bedPrices[this.Name].bigHigh; } if (BedsSmall > 0) { priceArray[0] += BedsSmall * Days[0] * Settings.bedPrices[this.Name].smallOut; priceArray[1] += BedsSmall * Days[1] * Settings.bedPrices[this.Name].smallLow; priceArray[2] += BedsSmall * Days[2] * Settings.bedPrices[this.Name].smallHigh; } priceArray[3] = priceArray[0] + priceArray[1] + priceArray[2]; Days[3] = Days[0] + Days[1] + Days[2]; TotalNoDiscount = priceArray[3]; priceArray[3] -= ((Discount / (decimal)100) * priceArray[3]); priceArray[3] = Decimal.Round(priceArray[3], 2); //if using Price items and not assingning to Price, Notify... wont work. Price = priceArray; }
public async Task <IActionResult> OnGetAsync(int accommodationId, string checkInDate, string checkOutDate) { if (accommodationId == 0) { return(BadRequest()); } if (User.Identity.IsAuthenticated) { CurrentUser = await userManager.FindByEmailAsync(User.Identity.Name); } AccommodationId = accommodationId; Accommodation = await AccommodationLogic.GetAccommodationByIdAsync(accommodationId); if (Accommodation == null) { return(NotFound()); } CheckInDateString = checkInDate; CheckOutDateString = checkOutDate; var dateformat = "dd.MM.yyyy."; var listOfDatesOccupied = await AccommodationLogic.GetDatesOccupiedForAccommodationAsync(accommodationId); try { CheckInDate = DateTime.ParseExact(checkInDate, dateformat, CultureInfo.InvariantCulture); CheckOutDate = DateTime.ParseExact(checkOutDate, dateformat, CultureInfo.InvariantCulture); if (CheckInDate < DateTime.Now.Date || CheckOutDate < DateTime.Now.AddDays(1).Date || CheckInDate >= CheckOutDate) { throw new Exception("Invalid dates!"); } if (!await AccommodationLogic.CheckIfBookingDatesAreValid(CheckInDate, CheckOutDate, accommodationId)) { throw new Exception("Dates are occupied!"); } } catch { CheckInDate = DateTime.Now.Date; CheckOutDate = DateTime.Now.Date; CheckInDateString = CheckInDate.ToString(dateformat); CheckOutDateString = CheckOutDate.ToString(dateformat); } DatesOccupiedArray = listOfDatesOccupied.ToArray(); var accommodationPhotosFolder = AccommodationLogic.GetPhotosFolderPathForAccommodation(Accommodation); HeaderPhotoPath = accommodationPhotosFolder + "Header/" + Accommodation.HeaderPhotoFileName; //removing wwwroot prefix HeaderPhotoPath = HeaderPhotoPath.Substring(7); try { AccommodationPhotos = Directory.GetFiles(accommodationPhotosFolder, "*", SearchOption.TopDirectoryOnly).ToList(); } catch (Exception) { AccommodationPhotos = new List <string>(); } return(Page()); }
public override string ToString() { return($"{CheckInDate.ToString("dd'/'MM'/'yyyy")} to {CheckOutDate.ToString("dd'/'MM'/'yyyy")}"); }