Ejemplo n.º 1
0
 public int GetEmptyPlacesCount(Route route, List<Ticket> tickets)
 {
     //emptyPlacesCount = all places count - buzy places count
     int emptyPlacesCount = route.Wagons.Select(w => w.WagonType.NumberOfPlaces).Sum() -
                            tickets.Where(t => t.Wagon.Route.Id == route.Id).Select(t => t.PlaceNumber).Count();
     return emptyPlacesCount;
 }
Ejemplo n.º 2
0
 public void EditRoute(Route route)
 {
     db.Entry(route).State = EntityState.Modified;
     db.SaveChanges();
 }
Ejemplo n.º 3
0
 public void DeleteRoute(Route route)
 {
     db.Routes.Remove(route);
     db.SaveChanges();
 }
Ejemplo n.º 4
0
 public void AddRoute(Route route)
 {
     db.Routes.Add(route);
     db.SaveChanges();
 }
Ejemplo n.º 5
0
 public void EditRoute(Route route)
 {
     _repository.EditRoute(route);
 }
Ejemplo n.º 6
0
 public void DeleteRoute(Route route)
 {
     _repository.DeleteRoute(route);
 }
Ejemplo n.º 7
0
 public void AddRoute(Route route)
 {
     _repository.AddRoute(route);
 }
Ejemplo n.º 8
0
        public ActionResult Edit(RouteAddViewModel routeEditViewModel)
        {
            if (!ModelState.IsValid)
            {
                routeEditViewModel.StationsListItems = _stationLogic.GetStationsListItems();
                return View(routeEditViewModel);
            }

            var start = _stationLogic.GetStationById(routeEditViewModel.StartingStation);
            var last = _stationLogic.GetStationById(routeEditViewModel.LastStation);

            StationRoute startingStation = _stationRouteLogic.GetStationRouteById(routeEditViewModel.StartingStationRoute);
            startingStation.Station = start;

            StationRoute lastStation = _stationRouteLogic.GetStationRouteById(routeEditViewModel.LastStationRoute);
            lastStation.Station = last;

            Route route = new Route
            {
                Id = routeEditViewModel.Id,
                Name = routeEditViewModel.Name,
                Number = routeEditViewModel.Number,
                StartingStation = startingStation,
                LastStation = lastStation,
                DepatureDateTime = routeEditViewModel.DepatureDate.AddHours(routeEditViewModel.DepatureTime.Hours)
                    .AddMinutes(routeEditViewModel.DepatureTime.Minutes),
                ArrivalDateTime = routeEditViewModel.ArrivalDate.AddHours(routeEditViewModel.ArrivalTime.Hours)
                    .AddMinutes(routeEditViewModel.ArrivalTime.Minutes)
            };

            _routeLogic.EditRoute(route);

            return RedirectToAction("Index");
        }