private bool EditRoute(RouteModel route)
        {
            var editWindow = new EditRouteWindow();
            var ctx        = (EditRouteViewModel)editWindow.DataContext;
            var routeCopy  = new RouteModel();

            CopyFields(route, routeCopy);
            ctx.Route               = routeCopy;
            ctx.Airports            = _airportService.GetAllAirports();
            ctx.Carriers            = _carrierService.GetAllCarriers();
            routeCopy.AirportDepart = ctx.Airports.Single(a => a.Id == routeCopy.AirportDepart.Id);
            routeCopy.AirportArrive = ctx.Airports.Single(a => a.Id == routeCopy.AirportArrive.Id);
            if (editWindow.ShowDialog() != true)
            {
                return(false);
            }
            var errs = GetModelErrors(routeCopy);

            if (errs != string.Empty)
            {
                ShowError(errs, "Error! Saving cancelled. ");
                return(false);
            }

            CopyFields(routeCopy, route);
            _routeService.EditRoute(route);
            return(true);
        }
Exemplo n.º 2
0
        public ActionResult AppointTrainToRoute(RouteViewModel routeViewModel)
        {
            var mapper   = new MapperConfiguration(cfg => cfg.CreateMap <RouteViewModel, RouteDTO>()).CreateMapper();
            var routeDto = mapper.Map <RouteViewModel, RouteDTO>(routeViewModel);

            _routeService.EditRoute(routeDto);
            return(RedirectToAction("ShowRoutes", "Admin"));
        }
Exemplo n.º 3
0
        public IActionResult Edit(RouteViewModel route)
        {
            //route.DepartureDate = route.DepartureDate.Date;
            var vehicle = _vehicleService.GetVehicleById(route.Vehicle.Id);

            if (vehicle == null)
            {
                return(NotFound());
            }
            //route.StartLocation = vehicle.StartLocation;
            //route.EndLocation = vehicle.EndLocation;

            var flag = _routeService.EditRoute(_mapper.Map <RouteSharedModel>(route));

            if (!flag)
            {
                return(NotFound());
            }
            return(RedirectToAction("Index"));
        }