public string ChangeScanningType(int laneId) { if (laneId == 0) { curentLaneId = 0; currentLaneNumber = 0; return("Alternating"); } curentLaneId = laneId; return(Lanes.FirstOrDefault(l => l.Id == laneId).Name); }
public string GetLaneTitle(long laneId) { long parentLaneId = 0; Lane parentLane = Lanes.FirstOrDefault(x => x.ChildLaneIds != null && x.ChildLaneIds.Contains(laneId)); if (parentLane != null) { parentLaneId = parentLane.Id.GetValueOrDefault(0); } if (parentLaneId != 0) { return(GetLaneTitle(parentLaneId) + ":" + GetLaneById(laneId).Title); } return(GetLaneById(laneId).Title); }
public Lane GetLaneById(long laneId) { Lane lane = Lanes.FirstOrDefault(x => x.Id == laneId); if (lane == null) { lane = Backlog.FirstOrDefault(x => x.Id == laneId); } if (lane == null) { lane = Archive.FirstOrDefault(x => x.Id == laneId); } return(lane); }
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."; } }
public void UpdateLane(Lane laneToUpdateWith) { //Try getting the lane from the Lanes Lane regularLaneToReplace = Lanes.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id); if (regularLaneToReplace != null) { int laneIndex = Lanes.IndexOf(regularLaneToReplace); Lanes.RemoveAt(laneIndex); Lanes.Insert(laneIndex, laneToUpdateWith); return; } //If none, try getting from Backlog Lane backLogLaneToReplace = Backlog.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id); if (backLogLaneToReplace != null) { int laneIndex = Backlog.IndexOf(backLogLaneToReplace); Backlog.RemoveAt(laneIndex); Backlog.Insert(laneIndex, laneToUpdateWith); return; } //Lastly, get it from Archive Lane archiveLaneToReplace = Archive.FirstOrDefault(lane => lane.Id == laneToUpdateWith.Id); if (archiveLaneToReplace != null) { int laneIndex = Archive.IndexOf(archiveLaneToReplace); Archive.RemoveAt(laneIndex); Archive.Insert(laneIndex, laneToUpdateWith); return; } throw new ItemNotFoundException("Could not find the Lane to replace with the updated Lane."); }
public ScannedStudent AddScannedStudenToFlight(ScannerInput card, int userId, int schoolId) { ScannedStudent result = null; CloseLaneStatus = ""; CloseFlightId = 0; var scannedStudent = new ScannedStudent(); using (var ds = new DataSeed()) { var student = ds.GetStudentByIdForDismissal(card.StudentId, schoolId); if (student == null) { Status = "Barcode not found"; return(null); } var parent = ds.GetParentById(card.ParentId); if (parent == null) { Status = "Barcode not found"; return(null); } var parentName = ds.StudentAlredyScanned(card.StudentId, SchoolId); if (parentName != null) { Status = "This student was picked up by " + parentName; return(null); } scannedStudent.ParentId = parent.Id; scannedStudent.ParentLicense = parent.DriverLicense; scannedStudent.StudentId = student.Id; scannedStudent.ParentName = parent.Name; scannedStudent.Name = student.Name; var dismissal = new Dismissal { StudentId = student.Id, ParentId = parent.Id, ScanTime = DateTime.Now, UserId = userId }; if (ScannerFlights == null || ScannerFlights.Count() == 0) { CreateNewFlight(ds, dismissal.UserId); } if (LaneLogistic == ScannerType.MultipleScanner) { var laneId = Lanes.FirstOrDefault(l => l.UserId == dismissal.UserId).Id; result = AddStudentToLane(ds, dismissal, laneId, scannedStudent); } else if (LaneLogistic == ScannerType.SingleScanner) { if (curentLaneId == 0) { result = AddStudentAltemating(ds, dismissal, scannedStudent); // default single scanner } else { result = AddStudentToLane(ds, dismissal, curentLaneId, scannedStudent); } } }; return(result); }