예제 #1
0
        public string ChangeLane(List <int> cardId, int laneId, int userId)
        {
            string parentName = null;
            int    prevl2fId;

            using (var ds = new DataSeed()) {
                var l2fObj = ScannerFlights.FirstOrDefault(p => p.LaneId == laneId);
                l2fObj = CheckIsLane(ds, userId, laneId, l2fObj);
                if (CountCarInLane(ds, userId, l2fObj, ""))
                {
                    l2fObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
                }
                if (LaneLogistic == ScannerType.SingleScanner && curentLaneId == 0)
                {
                    if (!isMoveRemoveCard)
                    {
                        currentLaneNumber = currentLaneNumber <= 0 ? (Lanes.Count() - 1) : (currentLaneNumber - 1);
                        isMoveRemoveCard  = true;
                    }
                    else if (isMoveRemoveCard && Lanes.ElementAt(currentLaneNumber >= (Lanes.Count() - 1) ? 0 : (currentLaneNumber + 1)).Id == laneId)
                    {
                        isMoveRemoveCard  = false;
                        currentLaneNumber = currentLaneNumber >= (Lanes.Count() - 1) ? 0 : (currentLaneNumber + 1);
                    }
                }

                l2fObj.CountCarsInLane += 1;
                parentName              = ds.ChangeLane(cardId, l2fObj.Flight2LaneId, l2fObj.CountCarsInLane, out prevl2fId);
            };

            if (prevl2fId != 0)
            {
                var prevObjL2F = ScannerFlights.FirstOrDefault(p => p.Flight2LaneId == prevl2fId);
                if (prevObjL2F != null)
                {
                    prevObjL2F.CountCarsInLane -= 1;
                }
            }
            return(parentName);
        }