Ejemplo n.º 1
0
        //Окно покупку билета

        public ActionResult PurchaseWindow(int trainId)
        {
            try {
                var seats = rs.AllRoutes().FirstOrDefault(t => t.Number == trainId).Seats.Where(s => s.Quantity > 0).Select(s => new SeatsViewModel(s.Type, s.Quantity, s.Price)).ToList();
                var train = rs.AllRoutes().FirstOrDefault(t => t.Number == trainId);
                var model = new PlaceViewModel(train.Number, train.Stops.Select(t => t.StopStation).ToList(), seats);
                return(View(model));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public ActionResult HomePage()
        {
            try {
                var routes = rs.AllRoutes();

                var trains = routes.Select(r => new TrainViewModel
                                           (
                                               r.Number,
                                               r.DepartureStation,
                                               r.ArrivalStation,
                                               r.Arrival,
                                               r.Departure,
                                               r.Stops.Select(t => new TransitionalViewModel(
                                                                  t.StopStation,
                                                                  t.Arrival,
                                                                  t.Departure
                                                                  )).ToList(),
                                               r.Seats.Select(s => new SeatsViewModel(
                                                                  s.Type,
                                                                  s.Quantity,
                                                                  s.Price
                                                                  )).ToList(),
                                               r.Passengers.Select(p => new PlaceViewModel(p.Id, p.Wagon, p.PassengerPlace, p.Price, p.TrainNumber, p.PassName, p.Type)).ToList(),
                                               r.CurrentRoute.Distance
                                           )

                                           ).ToList();

                var model = new SearchViewModel {
                    Trains = trains
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Ejemplo n.º 3
0
        //Список поездов

        public ActionResult AvailableTrains()
        {
            try
            {
                var routes = rs.AllRoutes();

                //Временная переменная для инициализации частичного представления
                TempData["Trains"] = routes.Select(r => new TrainViewModel
                                                   (
                                                       r.Number,
                                                       r.DepartureStation,
                                                       r.ArrivalStation,
                                                       r.Arrival,
                                                       r.Departure,
                                                       r.Stops.Select(t => new TransitionalViewModel(
                                                                          t.StopStation,
                                                                          t.Arrival,
                                                                          t.Departure
                                                                          )).OrderBy(d => d.Departure).ToList(),
                                                       r.Seats.Select(s => new SeatsViewModel(
                                                                          s.Type,
                                                                          s.Quantity,
                                                                          s.Price
                                                                          )).ToList(),
                                                       r.Passengers.Select(p => new PlaceViewModel(p.Id, p.Wagon, p.PassengerPlace, p.Price, p.TrainNumber, p.PassName, p.Type)).ToList(),
                                                       r.CurrentRoute.Distance
                                                   )

                                                   ).ToList();

                return(View());
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }