Esempio n. 1
0
        public ActionResult ReservePlace(int placeId)
        {
            var place = _runRepo.GetPlaceInRun(placeId);

            var reservation = _resServ.Reserve(place);
            var model       = new ReservationViewModel()
            {
                Reservation     = reservation,
                PlaceInRun      = place,
                PriceComponents = _priceCalculationStrategy.CalculatePrice(place),
                Date            = place.Run.Date,
                Train           = _trainRepo.GetTrainDetails(place.Run.TrainId),
            };

            return(View(model));
        }
Esempio n. 2
0
        public Ticket CreateTicket(int reservationId, string fName, string lName)
        {
            var res = _resRepo.Get(reservationId);

            if (res.TicketId != null)
            {
                throw new InvalidOperationException("ticket has been already issued to this reservation, unable to create another one");
            }

            var placeInRun = _runRepository.GetPlaceInRun(res.PlaceInRunId);

            var newTicket = new Ticket()
            {
                ReservationId   = res.Id,
                CreatedDate     = DateTime.Now,
                FirstName       = fName,
                LastName        = lName,
                Status          = TicketStatusEnum.Active,
                PriceComponents = new List <PriceComponent>()
            };

            newTicket.PriceComponents = _priceStr.CalculatePrice(placeInRun);

            res.TicketId = newTicket.Id;
            _resRepo.Update(res);

            _tickRepo.Create(newTicket);
            return(newTicket);
        }
Esempio n. 3
0
        public ActionResult ReservePlace(int placeId)
        {
            var place = _runRepo.GetPlaceInRun(placeId);

            var reservation = _resServ.Reserve(place);

            var model = new ReservationViewModel()
            {
                Reservation     = reservation,
                PlaceInRun      = place,
                PriceComponents = _strategyFactory.createCalculationStrategy(new Domain.DTO.StrategyDTO {
                    IncludeTea = true, IncludeCoffee = true
                }).CalculatePrice(place),
                Date  = place.Run.Date,
                Train = _trainRepo.GetTrainDetails(place.Run.TrainId),
            };

            return(View(model));
        }