예제 #1
0
        public ActionResult ChangeRoute(RouteViewModel model, List <TransitionalViewModel> modelItem)
        {
            try
            {
                var train = new TrainDTO
                {
                    Number           = model.Number,
                    DepartureStation = model.DepartureStation,
                    ArrivalStation   = model.ArrivalStation,
                    Departure        = model.Departure,
                    Seats            = model.Seats.Select(s => new SeatDTO
                    {
                        Type     = s.Type,
                        Quantity = s.Quantity,
                        Price    = s.Price
                    }).ToList(),
                    Stops = modelItem.Select(m => new StopoverDTO
                    {
                        StopStation = m.StopStation,
                        Departure   = m.Departure,
                        Arrival     = m.Arrival
                    }).ToList()
                };

                rs.EditRoute(train, train.Stops, model.SelectedRoute);
                Unit.Save();
                Unit.Dispose();
                return(RedirectToAction("AvailableTrains"));
            }
            catch (Exception ex) {
                return(View(ex.Message));
            }
        }
 public ActionResult Edit([Bind(Include = "RouteId,RouteName,UserId,Origin,OriginCoordinates,Destination,DestinationCoordinates,RouteLength")] Route route)
 {
     if (ModelState.IsValid)
     {
         _routeService.EditRoute(route);
         return(RedirectToAction("Index"));
     }
     return(View(route));
 }