Example #1
0
        public async Task <ActionResult> Reservation(HotelDetailItem hotelInfo)
        {
            var reservation = hotelInfo.ReservationRequest;

            if (_signInManager.IsSignedIn(User))
            {
                reservation.UserId = Guid.Parse((await _userManager.GetUserAsync(User)).Id);
                var response = await _reservationService.CreateReservationAsync(reservation);

                ViewBag.Response = response;

                if (response.IsSuccessful)
                {
                    TempData.Add("ReservationRequest", JsonConvert.SerializeObject(reservation));
                    return(Redirect($"/hotels/{reservation.HotelId}/roomtype/{reservation.RoomTypeId}"));
                }
                else
                {
                    hotelInfo = await _repository.GetDetails(reservation);

                    hotelInfo.ReservationRequest = reservation;

                    return(View("Details", hotelInfo));
                }
            }
            else
            {
                return(Redirect($"/account/login?returnUrl=/hotels/{reservation.HotelId}/roomtype/{reservation.RoomTypeId}"));
            }
        }