private async Task <DialogTurnResult> LastStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
        {
            this.hotelsearchstate = await this._welcomeUserStateAccessors.HotelSearchState.GetAsync(step.Context, () => new HotelReservation(), cancellationToken);

            if (this.hotelsearchstate != null && this.hotelsearchstate.CheckOutDate == null)
            {
                this.hotelsearchstate.CheckOutDate = Convert.ToDateTime(step.Context.Activity.Text);
            }

            // Save the state of the user
            await this._welcomeUserStateAccessors.HotelSearchState.SetAsync(step.Context, this.hotelsearchstate);

            await this._welcomeUserStateAccessors.UserState.SaveChangesAsync(step.Context);

            // Create Adaptive Card for confirmation view
            var cardAttachment = await this.CreateAdaptiveCardAttachmentAsync(@".\Resources\ResultCard.json", step.Context);

            var reply = step.Context.Activity.CreateReply();

            reply.Attachments = new List <Attachment>()
            {
                cardAttachment
            };
            await step.Context.SendActivityAsync(reply, cancellationToken);

            // Delete after click confirm
            await this._welcomeUserStateAccessors.HotelSearchState.SetAsync(step.Context, new HotelReservation());

            await this._welcomeUserStateAccessors.UserState.SaveChangesAsync(step.Context);

            return(await step.EndDialogAsync(cancellationToken));
        }
        public void RequestsDeclined()
        {
            List <Tuple <int, int> > listOfBookings = new List <Tuple <int, int> >();

            listOfBookings.Add(new Tuple <int, int>(1, 3));
            listOfBookings.Add(new Tuple <int, int>(2, 5));
            listOfBookings.Add(new Tuple <int, int>(1, 9));
            listOfBookings.Add(new Tuple <int, int>(0, 15));

            List <string> expected = new List <string>();

            expected.Add("Accept");
            expected.Add("Accept");
            expected.Add("Accept");
            expected.Add("Decline");

            List <string> actual = new List <string>();

            //size = 3
            HotelReservation hotelReservation = new HotelReservation(3);

            foreach (var tuple in listOfBookings)
            {
                actual.Add(hotelReservation.ReserveRoom(tuple));
            }

            for (int i = 0; i < listOfBookings.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        // DELETE: api/Employees/5

        public IHttpActionResult DeleteHotelReservation(int hotelReservationId)
        {
            //Hotel remove_hotel = db.Hotels.Find(hotelId);
            HotelReservation remove_hotel = _hotelReservationService.Queryable().Where(c => c.Id == hotelReservationId).FirstOrDefault();

            //bool remove_hotel_result =
            _hotelReservationService.Delete(remove_hotel.Id);

            if (remove_hotel == null)
            {
                return(NotFound());
            }

            //db.Hotels.Remove(remove_hotel);
            //try
            //{
            //   // db.SaveChanges();
            //}
            //catch (DbUpdateConcurrencyException ex)
            //{
            //    return BadRequest(ex.Message);
            //}

            return(Ok(remove_hotel));
        }
        public void RequestsOutsideOfPlanningPeriodDeclined()
        {
            List <Tuple <int, int> > listOfBookings = new List <Tuple <int, int> >();

            //1a
            listOfBookings.Add(new Tuple <int, int>(-4, 2));
            //1b
            listOfBookings.Add(new Tuple <int, int>(200, 400));

            List <string> expected = new List <string>();

            expected.Add("Decline");
            expected.Add("Decline");

            List <string> actual = new List <string>();

            //size = 1
            HotelReservation hotelReservation = new HotelReservation(1);

            foreach (var tuple in listOfBookings)
            {
                actual.Add(hotelReservation.ReserveRoom(tuple));
            }

            for (int i = 0; i < listOfBookings.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Example #5
0
 public IActionResult Index(HotelReservation model)
 {
     if (ModelState.IsValid)
     {
         return(RedirectToAction("ReservationSuccess"));
     }
     return(View("Index", model));
 }
Example #6
0
        static void Main(string[] args)
        {
            // TODO: Create instances of your object here and call methods.

            //new object reservations
            HotelReservation reservations = new HotelReservation("Dejan Cancar", 8);
            decimal          bleh         = reservations.ActualTotal(true, false);
        }
        public static void book(HotelReservation hotel, FlightReservation flight)
        {
            Reservation reservation = new Reservation();
            reservation.Flight = flight;
            reservation.Hotel = hotel;

            MessageQueue queue = new MessageQueue(Reservation.QUEUE_PATH);
            queue.Send(reservation);
        }
        public async Task SendReservationEmail(HotelReservation hotelReservation, RoomType roomType, IEnumerable <HotelPrice> dailyPrices,
                                               decimal vatAmount, int paidDays, string?country, string phoneNumber)
        {
            var hotel = await _meredithDbContext.Hotels
                        .Include(item => item.Translations)
                        .ThenInclude(item => item.Language)
                        .Include(item => item.Page)
                        .ThenInclude(item => item.Translations)
                        .ThenInclude(item => item.Language)
                        .Include(item => item.Spaces)
                        .ThenInclude(item => item.Translations)
                        .ThenInclude(item => item.Language)
                        .Include(item => item.Amenities)
                        .ThenInclude(item => item.Translations)
                        .ThenInclude(item => item.Language)
                        .Include(item => item.Rules)
                        .ThenInclude(item => item.Translations)
                        .ThenInclude(item => item.Language)
                        .FirstOrDefaultAsync(item => item.Id == roomType.HotelId);

            if (hotel?.CompanyId is null)
            {
                // I don't think this is possible and I don't see any hotel without a companyId in db either
                // I don't know why we marked this is nullable
                throw new Exception("Hotel is not connected to any company.");
            }

            var templateData = new
            {
                resort = new
                {
                    featuredImage = hotel.Page.FeaturedImage,
                    h2            = hotel.Page.Translations.FirstOrDefault(t => t.Language.Culture == "en-US")?.Title
                },
                numberOfGuests = hotelReservation.NumberOfGuests,
                checkIn        = hotelReservation.Start.ToString("ddd, d MMM"),
                checkOut       = hotelReservation.End.ToString("ddd, d MMM"),
                nightsCount    = paidDays,
                prices         = dailyPrices.Select(item => new
                {
                    date   = item.Date.ToString("ddd, d MMM"),
                    amount = Math.Round(item.Amount, 2)
                }),
                vat                 = Math.Round(vatAmount, 2),
                amount              = Math.Round(hotelReservation.Amount, 2),
                name                = hotelReservation.Name,
                phoneCountry        = country,
                phone               = phoneNumber,
                email               = hotelReservation.Email,
                message             = hotelReservation.Message,
                roomDescriptionHTML = GetRoomDescription(hotel)
            };

            var to = Tuple.Create(hotelReservation.User.Email, hotelReservation.User.UserName);

            await _sendGridService.SendEmail(hotel.CompanyId.Value, to, templateData);
        }
Example #9
0
        public ActionResult HotelReservation()
        {
            HotelReservation model = new HotelReservation();

            model.StartDate     = DateTime.Now;
            ViewData["message"] = String.Empty;

            return(View("hotel-reservation", model));
        }
        public ActionResult Book(int RoomId)
        {
            HotelReservation hr = new HotelReservation()
            {
                Room = db.HotelRooms.Include("Room").Include("Hotel").SingleOrDefault(x => x.Id == RoomId)
            };

            return(View(hr));
        }
Example #11
0
        public void TestActualTotal(bool usedMinibar, bool requiresCleaning, double expectedResult)
        {
            HotelReservation hr = new HotelReservation("Tommy", 1);

            decimal actaulResult = hr.AdditionalFees(usedMinibar, requiresCleaning);

            decimal expectedDecimalResult = decimal.Parse(expectedResult.ToString());

            Assert.AreEqual(expectedDecimalResult, actaulResult);
        }
Example #12
0
        public HotelReservationDTO FindById(int id)
        {
            HotelReservation reservation = uow.HotelReservations.FindById(id);

            if (reservation == null)
            {
                throw new Exception("Reservation with id " + id + " was not found");
            }

            return(Mapper.Map <HotelReservationDTO>(reservation));
        }
Example #13
0
        public void TestEstimatedTotal()
        {
            // Arrange
            HotelReservation ex = new HotelReservation("Billy", 2);

            // Act
            decimal actualResult = ex.EstimatedTotal;

            // Assert
            Assert.AreEqual(119.98M, actualResult);
        }
Example #14
0
        public void DeleteReservation(int reservationId)
        {
            HotelReservation reservation = uow.HotelReservations.FindById(reservationId);

            if (reservation == null)
            {
                throw new Exception("Order with id " + reservationId + " was not found");
            }

            uow.HotelReservations.Remove(reservation);
            uow.Save();
        }
Example #15
0
        /// <summary>
        /// If valid inputs, adds a hotel reservation to the trip when the user clicks "Add Reservation" button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void AddReservation_Click(object sender, RoutedEventArgs args)
        {
            if (CheckValidInputs())
            {
                string hotelName = Check.FormatName(uxHotelName.Text);
                string address   = uxHotelAddress.Text;

                string country  = Check.FormatName(uxCountry.Text);
                string region   = Check.FormatName(uxRegion.Text);
                string cityname = Check.FormatName(uxCity.Text);

                double   roomPrice   = double.Parse(uxRoomPrice.Text);
                DateTime checkInDate = (DateTime)uxCheckinDate.SelectedDate;

                int cityID = 0;
                SqlCommandExecutor executor = new SqlCommandExecutor(connectionString);

                //Lookup city
                City citysearch = executor.ExecuteReader(new LocationGetCityDelegate(cityname, country, region));

                //If city does not exist, add city
                if (citysearch == null)
                {
                    City city = executor.ExecuteNonQuery(new LocationCreateCityDelegate(cityname, region, country));
                    cityID = city.CityID;
                }
                else
                {
                    cityID = citysearch.CityID;
                }

                int hotelID = 0;

                //Lookup hotel
                Hotel hotelsearch = executor.ExecuteReader(new HotelsFetchHotelDelegate(hotelName, cityID, address));

                //If hotel does not exist, add hotel
                if (hotelsearch == null)
                {
                    Hotel hotel = executor.ExecuteNonQuery(new HotelsCreateHotelDelegate(hotelName, cityID, address));
                    hotelID = hotel.HotelID;
                }
                else
                {
                    hotelID = hotelsearch.HotelID;
                }

                //Add hotel reservation
                HotelReservation hr = executor.ExecuteNonQuery(new HotelsCreateHotelReservationDelegate(tripID, hotelID, checkInDate, roomPrice));

                MessageBox.Show("Reservation at " + hotelName + " successfully added");
            }
        }
Example #16
0
        public void AddHotelandTest_TC1()
        {
            string hotelName = "Lakewood";

            string customerType = "Regular";

            HotelReservation reservation = new HotelReservation();

            reservation.AddHotel(hotelName, customerType);

            Assert.AreEqual(1, reservation.list.Count);
        }
        public ActionResult Reservation(int Id)
        {
            HotelReservation hr = db.HotelReservations.Include("Guest")
                                  .Include("Room")
                                  .Include("Room.Room")
                                  .Include("Room.Hotel")
                                  .Include("Room.Hotel.City")
                                  .Include("Room.Hotel.City.Country")
                                  .SingleOrDefault(x => x.Id == Id);

            return(View(hr));
        }
Example #18
0
 public void SetUP()
 {
     _hotelReservation = new HotelReservation();
     _hotelReservation.AddHotel(new Hotel {
         name = "Lakewood", weekdayRatesRegular = 110, weekendRatesRegular = 90, weekdayRatesLoyalty = 80, weekendRatesLoyalty = 80, rating = 3
     });
     _hotelReservation.AddHotel(new Hotel {
         name = "Bridgewood", weekdayRatesRegular = 160, weekendRatesRegular = 60, weekdayRatesLoyalty = 110, weekendRatesLoyalty = 50, rating = 4
     });
     _hotelReservation.AddHotel(new Hotel {
         name = "Ridgewood", weekdayRatesRegular = 220, weekendRatesRegular = 150, weekdayRatesLoyalty = 100, weekendRatesLoyalty = 40, rating = 5
     });
 }
Example #19
0
        public void DeleteReservationTest()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);
            int numEx = uow.Object.HotelReservations.Get().Count - 1;

            HotelReservation reservation = uow.Object.HotelReservations.Get()[uow.Object.HotelReservations.Get().Count - 1];

            hrs.DeleteReservation(reservation.HotelReservationId);

            Assert.AreEqual(numEx, uow.Object.HotelReservations.Get().Count);
        }
 public void SetUP()
 {
     hotelReservation = new HotelReservation();
     hotelReservation.AddHotel(new Hotel {
         name = "Lakewood", weekdayRegularRates = 110, weekendRegularRates = 90, weekdayLoyaltyRates = 80, weekendLoyaltyRates = 80, rating = 3
     });
     hotelReservation.AddHotel(new Hotel {
         name = "Bridgewood", weekdayRegularRates = 160, weekendRegularRates = 60, weekdayLoyaltyRates = 110, weekendLoyaltyRates = 50, rating = 4
     });
     hotelReservation.AddHotel(new Hotel {
         name = "Ridgewood", weekdayRegularRates = 220, weekendRegularRates = 150, weekdayLoyaltyRates = 100, weekendLoyaltyRates = 40, rating = 5
     });
 }
        private async Task <DialogTurnResult> LocationStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
        {
            this.hotelsearchstate = await this._welcomeUserStateAccessors.HotelSearchState.GetAsync(step.Context, () => new HotelReservation(), cancellationToken);

            if (this.hotelsearchstate != null && !string.IsNullOrEmpty(this.hotelsearchstate.Region))
            {
                return(await step.NextAsync(this.hotelsearchstate.Region, cancellationToken));
            }
            else
            {
                return(await step.PromptAsync("regionPrompt", GenerateLocationOptions(step.Context.Activity), cancellationToken));
            }
        }
Example #22
0
        public void WhenGiven_StartDate_And_EndDate_To_FindHighestRatedHotel_ShouldReturn_HighestRatedHotel()
        {
            string       expected            = "Ridgewood";
            HotelDetails hotelDetailsTestObj = new HotelDetails();

            hotelDetailsTestObj.AddHotel("Lakewood", 3, 110, 90, 80, 80);
            hotelDetailsTestObj.AddHotel("Bridgewood", 4, 150, 50, 110, 50);
            hotelDetailsTestObj.AddHotel("Ridgewood", 5, 220, 150, 100, 40);
            HotelReservation hotelReservationTestOj = new HotelReservation(CustomerType.REGULAR_CUST, Convert.ToDateTime("11/09/2020"), Convert.ToDateTime("12/09/2020"));
            string           result = hotelReservationTestOj.FindHighestRatedHotel();

            Assert.AreEqual(expected, result);
        }
        public static HotelReservationBuilder Start()
        {
            _hotelReservation = new HotelReservation()
            {
                Description = "Reserva de Hotel",
                InputDate   = DateTime.Now,
                OutputDate  = DateTime.Now.AddDays(10),
                Hotel       = HotelBuilder.Start().Build(),
                HotelReservationCustomers = new List <Domain.Features.Flights.Customer>()
            };

            return(new HotelReservationBuilder());
        }
Example #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            HotelReservation hotelRes = new HotelReservation();
            hotelRes.DepartureDate = DateTime.Now;
            hotelRes.ArrivalDate = DateTime.Now;
            hotelRes.HotelId = 1;

            FlightReservation flightRes = new FlightReservation();
            flightRes.DepartureDate = DateTime.Now;
            flightRes.ArrivalDate = DateTime.Now;
            flightRes.FlightId = 1;
            ReservationService.book(hotelRes, flightRes);
        }
        public void GetCheapestHotel()
        {
            HotelReservation hotelReservation1 = new HotelReservation("LakeWood", 30000, "10Sep2020", "11Sep2020");
            HotelReservation hotelReservation2 = new HotelReservation("BridgeWood", 10000, "10Sep2020", "11Sep2020");
            HotelReservation hotelReservation3 = new HotelReservation("RidgeWood", 20000, "10Sep2020", "11Sep2020");
            HotelCheck       hotelCheck        = new HotelCheck();

            hotelCheck.hotelList.Add(hotelReservation1);
            hotelCheck.hotelList.Add(hotelReservation2);
            hotelCheck.hotelList.Add(hotelReservation3);
            string cheapestHotel = hotelCheck.findCheapestHotel();

            Assert.AreEqual("BridgeWood", cheapestHotel);
        }
        public ActionResult CancelHotelReservation(int Id, string uid)
        {
            HotelReservation hr = db.HotelReservations.Find(Id);

            ApplicationUser user = db.Users.Find(uid);

            user.Credit += float.Parse(hr.ReservationCost.ToString());


            db.HotelReservations.Remove(hr);
            db.SaveChanges();

            return(RedirectToAction("Reports", "Admin"));
        }
Example #27
0
        public void FindByIdTest()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);

            HotelReservation    reservation = uow.Object.HotelReservations.Get()[uow.Object.HotelReservations.Get().Count - 1];
            HotelReservationDTO res         = hrs.FindById(reservation.HotelReservationId);

            Assert.AreEqual(reservation.ClientName, res.ClientName);
            Assert.AreEqual(reservation.Hotel.Name, res.Hotel.Name);
            Assert.AreEqual(reservation.StartDate, res.StartDate);
            Assert.AreEqual(reservation.EndDate, res.EndDate);
        }
Example #28
0
        public void Reserve(HotelReservationDTO reservation)
        {
            HotelReservation newReservation = new HotelReservation()
            {
                ClientName      = reservation.ClientName,
                Hotel           = uow.Hotels.FindById(reservation.Hotel.Id),
                NumberOfPersons = reservation.NumberOfPersons,
                StartDate       = reservation.StartDate,
                EndDate         = reservation.EndDate
            };

            uow.HotelReservations.Create(newReservation);
            uow.Save();
        }
        public ActionResult CancelReservation(int Id)
        {
            HotelReservation hr = db.HotelReservations.Find(Id);

            ApplicationUser user = db.Users.Find(User.Identity.GetUserId());

            user.Credit += float.Parse(hr.ReservationCost.ToString());


            db.HotelReservations.Remove(hr);
            db.SaveChanges();

            return(RedirectToAction("MyHotelReservations", "Hotel"));
        }
        public async Task Deveria_criar_reserva_de_hotel_com_sucesso()
        {
            int expected = 1;

            HotelReservation reservation = HotelReservationBuilder.Start().Build();

            var cmd = HotelReservationRegisterCommandBuilder.Start().Build();

            _fakeMapper.Setup(x => x.Map <HotelReservation>(cmd)).Returns(reservation);

            var result = await _handler.Handle(cmd, It.IsAny <CancellationToken>());

            result.Should().BeTrue();
            _fakeRepository.Verify(x => x.Add(It.IsAny <HotelReservation>()), Times.Once);
        }
        public void GivenWeekdayAndWeekendDates_RegularCustomer_ReturnBestRatedHotel()
        {
            //Arrange
            HotelReservation.AddRatingsAndHotel();
            List <OutputHotel> expected = new List <OutputHotel> {
                new OutputHotel("Ridgewood", 5, 370)
            };
            DateTime checkinDate  = Convert.ToDateTime("11sep2020");
            DateTime checkoutDate = Convert.ToDateTime("12sep2020");

            //Act
            List <OutputHotel> actual = HotelReservation.FindBestRatedHotel(checkinDate, checkoutDate, CustomerType.REGULAR_CUSTOMER);

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
Example #32
0
        public HotelReservation theGuest_reservation(int reservationId)
        {
            HotelReservation hotelRes = db.HotelReservations
                                        .Include("Room.Hotel")
                                        .Include("Room")
                                        .Include("Room.Room")
                                        .Include("Guest")
                                        .Include("Room.Hotel.City")
                                        .Include("Room.Hotel.City.Country")
                                        .Include("Room.Hotel.Images")
                                        .Where(x => x.Id == reservationId &&
                                               ((x.Check_In_Date > DateTime.Now) || (x.Check_Out_Date < DateTime.Now)))
                                        .SingleOrDefault();

            return(hotelRes == null ? null : hotelRes);
        }