public async Task <ActionResult> Bookings(string tenant, int bookingId, int guestId, decimal roomPrice, int roomsCount, int roomId)
        {
            try
            {
                bool purchaseResult = false;

                var ticketPurchaseModel = new BookingPurchaseModel
                {
                    GuestId    = guestId,
                    TotalPrice = roomPrice
                };

                var tenantDetails = (_catalogRepository.GetTenantAsync(tenant)).Result;
                if (tenantDetails != null)
                {
                    SetTenantConfig(tenantDetails.TenantId, tenantDetails.TenantIdInString);

                    var hotelDetails = await _tenantRepository.GetHotelDetailsAsync(tenantDetails.TenantId);

                    var bookingsPurchaseId = await _tenantRepository.AddBookingPurchase(ticketPurchaseModel, tenantDetails.TenantId);

                    List <BookingModel> ticketsModel = BuildTicketModel(bookingId, roomId, roomsCount, bookingsPurchaseId);
                    purchaseResult = await _tenantRepository.AddBookings(ticketsModel, tenantDetails.TenantId);

                    var guest = HttpContext.Session.GetObjectFromJson <List <GuestModel> >("SessionUsers");

                    if (purchaseResult)
                    {
                        DisplayMessage(_localizer[$"You have successfully booked {roomsCount} rooms(s)."], "Confirmation");

                        var fromHotelEmailId = hotelDetails.AdminEmail;
                        var fromHotelName    = hotelDetails.HotelName;
                        var toEmailAddress   = guest[0].Email;
                        var fullName         = $"{guest[0].FirstName} {guest[0].LastName}";
                        var confirmMessage   = _localizer[$"You have successfully booked {roomsCount} rooms(s)."];

                        _emailService.SendEmailToGuests(fromHotelEmailId, fromHotelName, toEmailAddress, fullName, confirmMessage);
                    }
                    else
                    {
                        DisplayMessage(_localizer["Failed to book rooms."], "Error");
                    }
                }
                else
                {
                    return(View("TenantError", tenant));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(0, ex, "Booking rooms failed for tenant {tenant} and room {roomId}", tenant, bookingId);
                return(View("TenantError", tenant));
            }
            return(RedirectToAction("Index", "Bookings", new { tenant }));
        }
        public void AddBookingPurchaseTest()
        {
            var ticketPurchaseModel = new BookingPurchaseModel
            {
                BookedDate        = DateTime.Now,
                BookingPurchaseId = 12,
                GuestId           = 6,
                TotalPrice        = 5
            };

            var result = (_tenantRepository.AddBookingPurchase(ticketPurchaseModel, _tenantId)).Result;

            Assert.Equal(1, _numberOfBookingPurchases);
            Assert.Equal(12, result);
        }