public void DeleteBarcode(string barcode)
        {
            try
            {
                var barcodeToRemove = Barcodes.FirstOrDefault(f => f == barcode);

                Barcodes.Remove(barcodeToRemove);
            }
            catch (Exception ex)
            {
                MessageBox.Show(JsonConvert.SerializeObject(ex), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                Log.Error(ex);
            }
        }
        private async void SubmitCommandRecieverAsync()
        {
            try
            {
                Loader.StartLoading();

                var location = await _geolocationService.GetLastLocationAsync();

                Loader.StopLoading();

                var tags         = ConstantManager.Tags;
                var partnerModel = ConstantManager.Partner;

                if (Barcodes.Count() == 0)
                {
                    await _dialogService.DisplayAlertAsync("Error", "Error: Please add some scans.", "Ok");

                    return;
                }

                IEnumerable <BarcodeModel> empty = Barcodes.Where(x => x.Barcode.Count() == 0);
                if (empty.ToList().Count > 0)
                {
                    string result = await _dialogService.DisplayActionSheetAsync("Error? \n Some pallets have 0 scans. Do you want to edit them or remove the empty pallets.", null, null, "Remove empties", "Edit");

                    if (result == "Remove empties")
                    {
                        foreach (var item in empty.Reverse())
                        {
                            Barcodes.Remove(item);
                        }
                        if (Barcodes.Count == 0)
                        {
                            return;
                        }
                    }
                    if (result == "Edit")
                    {
                        await ItemTappedCommandRecieverAsync(empty.FirstOrDefault());

                        return;
                    }
                }

                List <string>    closedBatches = new List <string>();
                List <NewPallet> newPallets    = new List <NewPallet>();
                NewPallet        newPallet     = null;
                List <TItem>     palletItems   = new List <TItem>();
                TItem            palletItem    = null;

                foreach (var pallet in Barcodes)
                {
                    palletItem = new TItem
                    {
                        Barcode  = pallet.Barcode,
                        ScanDate = DateTimeOffset.UtcNow.Date,
                        TagsStr  = pallet.TagsStr
                    };

                    if (pallet.Tags != null)
                    {
                        foreach (var tag in pallet.Tags)
                        {
                            palletItem.Tags.Add(tag);
                        }
                    }
                    palletItems.Add(palletItem);

                    newPallet = new NewPallet
                    {
                        Barcode           = BatchId,
                        BuildDate         = DateTimeOffset.UtcNow.Date,
                        StockLocation     = partnerModel?.PartnerId,
                        StockLocationId   = partnerModel?.PartnerId,
                        StockLocationName = partnerModel?.FullName,
                        OwnerId           = AppSettings.CompanyId,
                        PalletId          = _uuidManager.GetUuId(),
                        ReferenceKey      = "",
                    };
                    if (tags != null)
                    {
                        foreach (var item in tags)
                        {
                            newPallet.Tags.Add(item);
                        }
                    }
                    foreach (var item in palletItems)
                    {
                        newPallet.PalletItems.Add(item);
                    }
                    newPallets.Add(newPallet);
                }

                bool accept = await _dialogService.DisplayAlertAsync("Close batch", "Mark this batch as completed?", "Yes", "No");

                if (accept)
                {
                    closedBatches = Barcodes.Select(x => x.Barcode).ToList();
                }

                Loader.StartLoading();
                ManifestModel model = model = GenerateManifest(location ?? new Xamarin.Essentials.Location(0, 0), newPallets, closedBatches);
                if (model != null)
                {
                    try
                    {
                        var current = Connectivity.NetworkAccess;
                        if (current == NetworkAccess.Internet)
                        {
                            ManifestModelGet manifestResult = await _moveService.PostManifestAsync(model, AppSettings.SessionId, Configuration.NewManifest);

                            try
                            {
                                AddorUpdateManifestOffline(model, false);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                            await GetPostedManifestDetail();
                        }
                        else
                        {
                            try
                            {
                                AddorUpdateManifestOffline(model, true);
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                            await GetPostedManifestDetail();
                        }
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                    }
                    finally
                    {
                        Loader.StopLoading();
                        model         = null;
                        tags          = null;
                        partnerModel  = null;
                        closedBatches = null;
                        newPallets    = null;
                        newPallet     = null;
                        palletItems   = null;
                        Cleanup();
                    }
                }
                else
                {
                    await _dialogService.DisplayAlertAsync("Alert", "Something goes wrong please check again", "Ok");
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                Loader.StopLoading();
            }
        }
        public void DeleteBarcode(string barcode)
        {
            var barcodeToRemove = Barcodes.First(f => f == barcode);

            Barcodes.Remove(barcodeToRemove);
        }