Example #1
0
        public async Task <ActionResult> Booking(SearchTripViewModel item, SeatSearchViewModel item2, MainSearchBind bind)
        {
            IEnumerable <AllrSeatsProcedureDTO> allrSeatsDto = await _routeService.SearchAllSeatById(item.Id, bind.From, bind.To, item2.Car);

            var allseats = _mapperTrip.Map <IEnumerable <AllrSeatsProcedureDTO>, List <AllSeatsProcedureViewModel> >(allrSeatsDto);

            foreach (var seat in allseats)
            {
                seat.Price = await _costService.GetCostOfSeatAsync(seat.PriceCoeff, item.Duration, (int)item.ArrivalTime.DayOfWeek);

                seat.SalePrice = await _costService.GetSaleCostOfSeatAsync(seat.PriceCoeff, item.Duration, (int)item.ArrivalTime.DayOfWeek);
            }

            var cars = allseats
                       .GroupBy(u => u.CarNumber)
                       .Select(grp => grp.ToList())
                       .ToList();

            AllSeatsViewModel <AllSeatsProcedureViewModel> viewModel =
                new AllSeatsViewModel <AllSeatsProcedureViewModel>
            {
                Trip = GetTripViewModel(item, item2, bind),
                Cars = cars
            };

            return(View(viewModel));
        }