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; }
public void EditRoute(Route route) { db.Entry(route).State = EntityState.Modified; db.SaveChanges(); }
public void DeleteRoute(Route route) { db.Routes.Remove(route); db.SaveChanges(); }
public void AddRoute(Route route) { db.Routes.Add(route); db.SaveChanges(); }
public void EditRoute(Route route) { _repository.EditRoute(route); }
public void DeleteRoute(Route route) { _repository.DeleteRoute(route); }
public void AddRoute(Route route) { _repository.AddRoute(route); }
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"); }