private void OnRoutePointRemoved(RoutePointRemovedEvent obj) { RoutePoint routePoint = RoutePoints.FirstOrDefault(x => x.Id == obj.RoutePointId); if (routePoint != null) { RoutePoints.Remove(routePoint); } AircraftRouteViewModel routeViewModel = Routes.FirstOrDefault(x => x.AircraftId == obj.AircraftId); if (routeViewModel != null) { Routes.Remove(routeViewModel); } Aircraft aircraft = Aircrafts.FirstOrDefault(x => x.Id == obj.AircraftId); if (aircraft != null) { AircraftRouteViewModel route = _routeService.GetRouteLine(aircraft); route.IsSelected = true; Routes.Add(route); } }
private void OnAircraftRemoved(AircraftRemovedEvent obj) { List <RoutePoint> routePointsToRemove = RoutePoints.Where(x => x.AircraftId == obj.AircraftId).ToList(); AircraftRouteViewModel routeToRemove = Routes.FirstOrDefault(x => x.AircraftId == obj.AircraftId); if (routePointsToRemove.Any()) { foreach (RoutePoint routePoint in routePointsToRemove) { RoutePoints.Remove(routePoint); } } if (routeToRemove != null) { Routes.Remove(routeToRemove); } }