public JsonResult BookRoom(BookingInfoViewModel bookingInfo)
        {
            string result = string.Empty;

            try
            {
                var a = DateTime.Now;
                var generatedBookingId = Guid.NewGuid();
                var toInsert           = new BookingInfo
                {
                    Id            = generatedBookingId,
                    EmailAddress  = bookingInfo.EmailAddress,
                    PeopleStaying = bookingInfo.PeopleStaying,
                    RoomBookDate  = new RoomBookDate
                    {
                        BookingInfoId = generatedBookingId,
                        CreatedDate   = DateTime.Now,
                        DateFrom      = DateTime.Parse(bookingInfo.DateFrom),
                        DateTo        = DateTime.Parse(bookingInfo.DateFrom).AddDays(1),
                        RoomId        = bookingInfo.RoomId
                    }
                };

                _bookingService.AddBooking(toInsert);
                result = "Successfully proccesed your booking. Thankyou very much!";
            }
            catch (Exception ex)
            {
                result = "Cannot process your booking as of the moment. Please try again later.";
            }

            return(new JsonResult(result));
        }
Beispiel #2
0
        public async Task <IActionResult> Info(CancellationToken token)
        {
            if (!Request.Query.ContainsKey("companyId") || !Request.Query.ContainsKey("bookingId"))
            {
                return(NotFound());
            }

            Request.Query.TryGetValue("companyId", out var companyId);
            var company = await _companyRepository.FindByIdAsync(long.Parse(companyId), token);

            Request.Query.TryGetValue("bookingId", out var bookingId);
            var tickets            = (await _ticketRepository.FindByBookingIdAsync(Guid.Parse(bookingId), token)).ToList();
            var currentFilmSession = await _filmSessionRepository.FindByIdAsync(tickets.First().FilmSession.Id, token);

            var poster = _blobRepository.Get(currentFilmSession.Film.Id);

            var viewModel = new BookingInfoViewModel
            {
                Company          = company,
                Film             = currentFilmSession.Film,
                FilmSession      = currentFilmSession,
                Poster           = poster,
                Money            = tickets.Count * currentFilmSession.Price,
                Tickets          = tickets,
                ConfirmationCode = tickets.First().ConfirmationCode
            };

            return(View(viewModel));
        }
 public void SetUp()
 {
     _viewModel = new BookingInfoViewModel(
         _mockDataServices.Object,
         _mockDialogService.Object,
         _mockEventManager.Object,
         _mockUnityContainer.Object,
         _mockRegionManager.Object,
         _mockKarveNavigator.Object,
         _mockConfigurationService.Object,
         _mockRequestController.Object,
         this._bookingLogicService.Object);
 }
Beispiel #4
0
        public async Task <IActionResult> IndexAsync()
        {
            var userId = _userRepository.FindByNameAsync(HttpContext.User.Identity.Name).Result.Id;

            var bookings = await _bookingRepository.GetByUserId(userId);

            BookingInfoViewModel viewModel = new BookingInfoViewModel
            {
                Bookings = bookings
            };

            return(View(viewModel));
        }
        public void SetUp()
        {
            _viewModel = new BookingInfoViewModel(
                _mockDataServices.Object,
                _mockDialogService.Object,
                _mockEventManager.Object,
                _mockUnityContainer.Object,
                _mockRegionManager.Object,
                _mockKarveNavigator.Object,
                _mockRequestController.Object);


            // _mockDataServices.Setup(

            //     _navigator.Setup(x => x.NewClientView(It.IsAny<Uri>()))
            // .Callback(() => { isClientNavigated = true; });)
        }
Beispiel #6
0
        public ActionResult ViewPrices(DataSelectorInputModel model)
        {
            if (DateTime.Compare(model.Arrival, DateTime.UtcNow) < 0)
            {
                this.TempData["Error"] = "Date cannot be in the past";
                return(this.Redirect("Index"));
            }

            if (DateTime.Compare(model.Arrival, model.Departure) > 0)
            {
                this.TempData["Error"] = "Arrival date should be earlier than departure";
                return(this.RedirectToAction("Index"));
            }

            var hotelId        = int.Parse(model.HotelName);
            var freeHotelRooms = this.hotelRooms
                                 .GetAllFreeRoomsInHotelForPeriod(hotelId, model.Capacity, model.Arrival, model.Departure)
                                 .GroupBy(hr => hr.Room.Type)
                                 .ToArray();

            IList <ListRoomsViewModel> rooms = new List <ListRoomsViewModel>();

            foreach (var roomType in freeHotelRooms)
            {
                var room = this.Mapper.Map <HotelRoomViewModel>(roomType.First());
                rooms.Add(new ListRoomsViewModel()
                {
                    Room  = room,
                    Count = roomType.Count()
                });
            }

            var viewModel = new BookingInfoViewModel()
            {
                Rooms     = rooms,
                Arrival   = model.Arrival,
                Departure = model.Departure,
                HotelId   = hotelId
            };

            return(this.View(viewModel));
        }