Пример #1
0
        public void CreateNewFlight(DataSeed ds, int userId)
        {
            var flight = new Flight
            {
                Date     = DateTime.Today,
                Number   = FlightNumber,
                StatusId = (int)Enums.FlightStatus.Open,
                SchoolId = SchoolId
            };

            flight.Id = ds.CreateFlight(flight);
            Flights.Add(flight);
            var lanes2Fights = ds.GetLanes2FlightsByFlightId(SchoolId, flight.Id, userId);

            foreach (var item in lanes2Fights)
            {
                ScannerFlights.Add(new ScannerFlight {
                    FlightId        = flight.Id,
                    FlightNumber    = flight.Number,
                    Flight2LaneId   = item.Id,
                    LaneId          = item.LaneId,
                    LaneStatusId    = item.StatusId,
                    CountCarsInLane = ds.GetCountCardsByLane2FlightId(item.Id)
                });
            }

            FlightNumber++;
        }
Пример #2
0
 private void SetCurrentFlight(DataSeed ds, int userId)
 {
     if (Flights == null || Flights.Count() == 0)
     {
         FlightNumber = ds.GetLastFlightNumberFromArchive(SchoolId) + 1;
         return;
         //CreateNewFlight(1, ds, userId);
     }
     else
     {
         var openFlights = Flights.Where(p => p.StatusId == (int)Enums.FlightStatus.Open).ToList();
         if (openFlights != null)
         {
             foreach (var item in openFlights)
             {
                 var lanes2Fights = ds.GetLanes2FlightsByFlightId(SchoolId, item.Id, userId);
                 for (int i = 0; i < lanes2Fights.Count(); i++)
                 {
                     var l2fObj = lanes2Fights.ElementAt(i);
                     if (l2fObj.StatusId == (int)Enums.LaneStatus.Closed)
                     {
                         lanes2Fights.Remove(l2fObj);
                         i--;
                     }
                     else
                     {
                         ScannerFlights.Add(new ScannerFlight
                         {
                             FlightId        = item.Id,
                             FlightNumber    = item.Number,
                             Flight2LaneId   = l2fObj.Id,
                             LaneId          = l2fObj.LaneId,
                             LaneStatusId    = l2fObj.StatusId,
                             CountCarsInLane = ds.GetCountCardsByLane2FlightId(l2fObj.Id)
                         });
                     }
                 }
             }
         }
         FlightNumber = ds.GetFlightNumber(SchoolId) + 1;
     }
 }