public async Task <IActionResult> Complete(ReservationDetailViewModel currentReservation)
        {
            bool isReserved;

            if (currentReservation.Guest.GuestId > 0)
            {
                _guestService.EditGuest(currentReservation.Guest);
                isReserved = _reservationService.AddReservation(currentReservation);
            }
            else
            {
                var newGuestId = _guestService.AddGuest(currentReservation.Guest);
                var newGuest   = await _guestService.GetGuest(newGuestId);

                currentReservation.Guest = newGuest;
                isReserved = _reservationService.AddReservation(currentReservation);
            }
            if (isReserved)
            {
                //ViewBag.Message = "Reservation completed succesfully!";
                ViewBag.Succes = 1;
            }
            else
            {
                ViewBag.Message = "Reservation failed!";
                ViewBag.Succes  = 1;
            }
            return(View(nameof(Index), await _reservationService.AllReservations()));
        }
Example #2
0
 // GET: Reservation
 public async Task <IActionResult> Index()
 {
     return(View(await _reservationService.AllReservations()));
 }