예제 #1
0
        //by laneId
        private ScannedStudent AddStudentToLane(DataSeed ds, Dismissal dismissal, int laneId, ScannedStudent scannedStudent)
        {
            var lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);

            lane2FlightObj = CheckIsLane(ds, dismissal.UserId, laneId, lane2FlightObj);
            //check isLanefull
            if (CountCarInLane(ds, dismissal.UserId, lane2FlightObj, scannedStudent.ParentLicense))
            {
                lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
            }

            if (ds.IsCarExistInPrevLane(lane2FlightObj.Flight2LaneId, scannedStudent.ParentLicense))
            {
                lane2FlightObj.CountCarsInLane -= 1;
            }

            dismissal.FlightLaneId          = lane2FlightObj.Flight2LaneId;
            scannedStudent.FlightNumber     = lane2FlightObj.FlightNumber;
            scannedStudent.FligthId         = lane2FlightObj.FlightId;
            lane2FlightObj.CountCarsInLane += 1;
            dismissal.CarNumber             = lane2FlightObj.CountCarsInLane;
            scannedStudent.CardId           = ds.AddStudentToDismissal(dismissal);
            if (scannedStudent.CardId == 0)
            {
                lane2FlightObj.CountCarsInLane -= 1;
                Status = "Barcode did not save. Please, try to scanne again!";
                return(null);
            }
            scannedStudent.Lane = Lanes.Where(p => p.Id == lane2FlightObj.LaneId).FirstOrDefault();

            return(scannedStudent);
        }
예제 #2
0
        //Altemating
        private ScannedStudent AddStudentAltemating(DataSeed ds, Dismissal dismissal, ScannedStudent scannedStudent)
        {
            isMoveRemoveCard = false;
            var laneId         = Lanes.ElementAt(currentLaneNumber).Id;
            var lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);

            lane2FlightObj = CheckIsLane(ds, dismissal.UserId, laneId, lane2FlightObj);

            if (!ds.IsCarExistInPrevLane(lane2FlightObj.Flight2LaneId, scannedStudent.ParentLicense))
            {
                currentLaneNumber = currentLaneNumber >= (Lanes.Count() - 1) ? 0 : (currentLaneNumber + 1);
                laneId            = Lanes.ElementAt(currentLaneNumber).Id;
                lane2FlightObj    = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
            }
            else
            {
                lane2FlightObj.CountCarsInLane -= 1;
            }

            lane2FlightObj = CheckIsLane(ds, dismissal.UserId, laneId, lane2FlightObj);

            //check isLanefull
            if (CountCarInLane(ds, dismissal.UserId, lane2FlightObj, scannedStudent.ParentLicense))
            {
                lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
            }

            dismissal.FlightLaneId          = lane2FlightObj.Flight2LaneId;
            lane2FlightObj.CountCarsInLane += 1;
            dismissal.CarNumber             = lane2FlightObj.CountCarsInLane;
            scannedStudent.CardId           = ds.AddStudentToDismissal(dismissal);
            scannedStudent.FlightNumber     = lane2FlightObj.FlightNumber;
            scannedStudent.FligthId         = lane2FlightObj.FlightId;
            if (scannedStudent.CardId == 0)
            {
                lane2FlightObj.CountCarsInLane -= 1;
                Status = "Barcode did not save. Please, try to scanne again!";
                return(null);
            }
            scannedStudent.Lane = Lanes.Where(p => p.Id == lane2FlightObj.LaneId).FirstOrDefault();

            return(scannedStudent);
        }