public void CloseLane(int laneId) { ScannerFlight l2fObj = null; using (var ds = new DataSeed()) { l2fObj = ScannerFlights.FirstOrDefault(p => p.LaneId == laneId); if (l2fObj == null) { return; } ds.CloseLane(l2fObj.Flight2LaneId); ScannerFlights.Remove(l2fObj); if (ScannerFlights.Where(s => s.FlightId == l2fObj.FlightId).Count() == 0) { ds.ChangeFlightStatus(l2fObj.FlightId, (int)Enums.FlightStatus.Closed); CloseFlightId = l2fObj.FlightId; Flights.FirstOrDefault(f => f.Id == l2fObj.FlightId).StatusId = 2; } CloseLaneStatus = "The " + Lanes.FirstOrDefault(p => p.Id == laneId)?.Color + " Lane from Flight " + l2fObj.FlightNumber + " was closed."; } }