public string RemoveCard(List <int> cardId, out int flightId) { string message = null; flightId = 0; int l2fId; bool isHasParentOtherStudent; using (var ds = new DataSeed()) { if (LaneLogistic == ScannerType.SingleScanner && curentLaneId == 0) { if (!isMoveRemoveCard) { currentLaneNumber = currentLaneNumber <= 0 ? (Lanes.Count() - 1) : (currentLaneNumber - 1); } else { isMoveRemoveCard = false; } } message = ds.RemoveDissmisalCard(cardId, out l2fId, out isHasParentOtherStudent); }; if (l2fId != 0) { var objL2F = ScannerFlights.FirstOrDefault(p => p.Flight2LaneId == l2fId); if (objL2F != null) { if (!isHasParentOtherStudent) { objL2F.CountCarsInLane -= 1; } } if (IsFlightEmpty(objL2F.FlightId)) { int flId = objL2F.FlightId; bool isDelete = false; using (var ds = new DataSeed()) { isDelete = ds.DeleteFlightById(flId); } if (isDelete) { FlightNumber--; for (int i = 0; i < ScannerFlights.Count(); i++) { if (ScannerFlights[i].FlightId == flId) { ScannerFlights.RemoveAt(i); i--; } } Flight flight = Flights.FirstOrDefault(f => f.Id == flId); Flights.Remove(flight); flightId = flId; } } } return(message); }