/******************************************************************* * 2.Check Guest: if already registered get guest details from db * if not registered get details from guest *********************************************************************/ public async Task <IActionResult> CheckGuest(int[] selectedRoomIDs, /*string lastName,*/ ReservationDetailViewModel currentReservation) { //Add selected rooms to current reservation foreach (var id in selectedRoomIDs) { currentReservation.Rooms.Add(await _roomService.GetRoom(id)); } //calculate the total price currentReservation.TotalPrice = Calculation.CalculatePrice(currentReservation); var guest = await _guestService.GetGuestByName(currentReservation.Guest.LastName); //if guest already registered if (guest != null) { ViewBag.Message = "Guest is already registered. Please update guest details if necessary."; currentReservation.Guest = guest; return(View(nameof(ConfirmReservation), currentReservation)); } //if guest not registered to create a new guest get details from guest else { ViewBag.Message = "Guest is not already registered. Please fill guest details."; //currentReservation.Guest = new GuestViewModel { LastName = lastName }; return(View(nameof(ConfirmReservation), currentReservation)); } }