Ejemplo n.º 1
0
        public ActionResult AddWagons(WagonAddViewModel wagonAddViewModel)
        {
            if (!ModelState.IsValid)
            {
                wagonAddViewModel.WagonTypeListItems = _wagonTypeLogic.GetWagonTypeListItems();
                return View(wagonAddViewModel);
            }

            Route route = _routeLogic.GetRouteById(wagonAddViewModel.RouteId);
            WagonType wagonType = _wagonTypeLogic.GetWagonTypeById(wagonAddViewModel.WagonType);

            for (int i = 0; i < wagonAddViewModel.NumberOfWagons; i++)
            {
                Wagon wagon = new Wagon
                {
                    Number = i + 1,
                    WagonType = wagonType,
                    Tickets = new List<Ticket>()
                };
                route.Wagons.Add(wagon);
            }

            _routeLogic.EditRoute(route);

            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
        public ActionResult AddWagons(int id)
        {
            Route route = _routeLogic.GetRouteById(id);
            WagonAddViewModel wagonAddViewModel = new WagonAddViewModel
            {
                RouteId = route.Id,
                WagonTypeListItems = _wagonTypeLogic.GetWagonTypeListItems()
            };

            return View(wagonAddViewModel);
        }