Esempio n. 1
0
        // GET: Booking/Details/5
        public async Task <IActionResult> Details(Guid id, string message = null)
        {
            var booking = await _unitOfWork.Bookings.GetByIdWithTenant(id);

            var userId = _userManager.GetUserId(User);

            var isUser = IsTenantOfBooking(booking, userId);
            var isHost = IsHostOfBooking(booking, userId);

            if (!isUser && !isHost)
            {
                return(Forbid());
            }

            booking.Listing = await _unitOfWork.Listings.GetByIdWithAccessories(booking.ListingId);

            var model = _mapper.Map <BookingDetailsViewModel>(booking);

            model.IsUser       = isUser;
            model.IsHost       = isHost;
            model.ErrorMessage = message;

            model.CardLast4Digits = await _stripe.
                                    GetCustomerCardDetailsAsync(booking.StripeCustomerIdToken);

            return(View(model));
        }