Exemplo n.º 1
0
        public IActionResult AddReservation(BookRoom book)
        {
            if (ModelState.IsValid)
            {
                Guest guest = _guestRepository.FindGuestById(book.guest.GuestId);
                if (guest == null)
                {
                    _guestRepository.AddNewGuest(book.guest);
                }
                Booking newBook = new Booking()
                {
                    CheckIn  = checkIn,
                    CheckOut = checkOut,
                    RoomId   = book.RoomId,
                    GuestId  = book.guest.GuestId
                };

                _bookRepository.AddNewReservation(newBook);
            }

            return(RedirectToAction("Index", "Home"));
        }