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())); }
public IActionResult Edit(int id, GuestViewModel guest) { if (id != guest.GuestId) { return(NotFound()); } if (ModelState.IsValid) { bool res = _guestService.EditGuest(guest); if (!res) { return(NotFound()); } return(RedirectToAction(nameof(Index))); } return(View(guest)); }
public async Task <IActionResult> Edit(int id, GuestViewModel guest) { if (id != guest.GuestId) { return(NotFound()); } if (ModelState.IsValid) { bool res = _guestService.EditGuest(guest); if (!res) { return(NotFound()); } ViewBag.Message = $"The guest {guest.LastName} has updated succesfully!"; ViewBag.Succes = 1; return(View(nameof(Index), await _guestService.AllGuests())); } return(View(guest)); }