public BarcodeReading RegisterBarcodeScan(string scannedBarcode) { BarcodeReading br = ParseBarcode(scannedBarcode); if (!DoesThisJobHaveAColorAssigned(br.Job)) { throw new Exception(string.Format("JOB {0} does not have an assigned color", br.Job)); } if (!IsBarcodeDataCorrect(br)) { throw new Exception(string.Format("Job")); } br.ScanDate = DateTime.Now; Barcodes barcode = GetBarcodes().FirstOrDefault(x => x.Barcode == br.Barcode); if (barcode == null) { barcode = new Barcodes() { Barcode = br.Barcode, Job = br.Job, Line = br.Line, ScanDate = br.ScanDate, SentDatabase = false, SentPrint = false, Tag = br.Tag }; AddBarcode(barcode); } return(br); }
private bool IsBarcodeInfoCorrect(BarcodeReading barcode) { List <JobShippingLabelColor> existingJobColors = GetJobShippingLabelColors(); existingJobColors.Any(x => x.Job == barcode.Job && !string.IsNullOrEmpty(x.Color)); return(true); }
private bool IsBarcodeDataCorrect(BarcodeReading barcode) { List <RegisteredTag> tags = GetRegisteredTags(); if (!tags.Any(x => x.Job.Trim().ToUpper() == barcode.Job.Trim().ToUpper())) { throw new Exception(string.Format("Job {0} is not registered", barcode.Job)); } if (!tags.Any(x => x.Job.Trim().ToUpper() == barcode.Job.Trim().ToUpper() && x.Floor.Trim().ToUpper() == barcode.Floor.Trim().ToUpper())) { throw new Exception(string.Format("Floor {0} does not belong to {1} job", barcode.Floor, barcode.Job)); } if (!tags.Any(x => x.Job.Trim().ToUpper() == barcode.Job.Trim().ToUpper() && x.Floor.Trim().ToUpper() == barcode.Floor.Trim().ToUpper() && x.Tag.Trim().ToUpper() == barcode.Tag.Trim().ToUpper())) { throw new Exception(string.Format("Tag {0} does not belong to the Floor {1} from {2} job", barcode.Tag, barcode.Floor, barcode.Job)); } return(true); }