internal void AssignValueToAddPalletAsync(string _batchId, IList <BarcodeModel> barcodes)
 {
     try
     {
         if (barcodes.Count == 0)
         {
             PalletCollection.Clear();
             Kegs = default;
         }
         else if (!PalletCollection.Any(x => x.BatchId == _batchId))
         {
             PalletCollection.Add(new PalletModel()
             {
                 Barcode = barcodes, Count = barcodes.Count(), BatchId = _batchId
             });
             CountKegs();
         }
         else
         {
             PalletCollection.Where(x => x.BatchId == _batchId).FirstOrDefault().Barcode = barcodes;
             PalletCollection.Where(x => x.BatchId == _batchId).FirstOrDefault().Count   = barcodes.Count;
             CountKegs();
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Exemple #2
0
        private void AssignInitialValue(ManifestModel manifestModel)
        {
            try
            {
                NewBatchModel            = manifestModel?.NewBatches.FirstOrDefault();
                SizeButtonTitle          = manifestModel?.Size;
                DestinationTitle         = manifestModel?.OwnerName;
                ManifestId               = manifestModel?.ManifestId;
                ConstantManager.Barcodes = manifestModel?.BarcodeModels;

                try
                {
                    PartnerModel partner = new PartnerModel()
                    {
                        PartnerId = manifestModel?.ReceiverId,
                        FullName  = manifestModel?.OwnerName
                    };
                    ConstantManager.Partner = partner;
                    if (manifestModel.Tags != null)
                    {
                        ConstantManager.Tags = new List <Tag>();
                        foreach (var item in manifestModel.Tags)
                        {
                            ConstantManager.Tags.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }

                foreach (var item in manifestModel.NewPallets)
                {
                    PalletModel palletModel = new PalletModel
                    {
                        Count      = item.PalletItems.Count,
                        ManifestId = ManifestId,
                        BatchId    = item.PalletId
                    };
                    palletModel.Barcode = ConstantManager.Barcodes;
                    if (PalletCollection == null)
                    {
                        PalletCollection = new List <PalletModel>();
                    }
                    PalletCollection.Add(palletModel);
                    IsPalletze = item.IsPalletze;
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
 internal void AssignFillScanValue(IList <BarcodeModel> _barcodes, string _batchId)
 {
     try
     {
         PalletModel pallet = PalletCollection.Where(x => x.BatchId == _batchId).FirstOrDefault();
         if (pallet != null)
         {
             using (var db = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()).BeginWrite())
             {
                 pallet.Barcode = _barcodes;
                 pallet.Count   = _barcodes.Count();
                 db.Commit();
             }
         }
         else
         {
             PalletCollection.Add(new PalletModel()
             {
                 Barcode = _barcodes,
                 Count   = _barcodes.Count(),
                 BatchId = _batchId,
             });
         }
         if (PalletCollection.Sum(x => x.Count) > 1)
         {
             Kegs = string.Format("({0} Kegs)", PalletCollection.Sum(x => x.Count));
         }
         else
         {
             Kegs = string.Format("({0} Keg)", PalletCollection.Sum(x => x.Count));
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }