public ActionResult CreateRouteStation(RouteStationViewModel route) { try { var routeStationDTO = new RouteStationDTO { TimeArrival = route.TimeArrival, TimeDeparture = route.TimeDeparture, RouteId = route.RouteId, StationId = route.StationId, StationName = _stationService.GetStation(route.StationId).Name }; _routeStationService.MakeRouteStation(routeStationDTO); return(Content("Вы успешно создали маршрут")); } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); } return(View(route)); }
public void AddRouteStation(int stationId, int routeId, RouteStationDTO routeStationDTO) { using (var uow = UnitOfWorkProvider.Create()) { var routeStation = Mapper.Map <RouteStation>(routeStationDTO); var route = routeRepository.GetById(routeId, s => s.RouteStations); var station = stationRepository.GetById(stationId, s => s.RouteStations); routeStation.Route = route; route.RouteStations.Add(routeStation); routeStation.Order = route.RouteStations.Count(); routeStation.Station = station; station.RouteStations.Add(routeStation); routeStationRepository.Insert(routeStation); uow.Commit(); } }
public void AddRouteStation(int stationId, int routeId, RouteStationDTO routeStationDTO) { routeService.AddRouteStation(stationId, routeId, routeStationDTO); }