public async Task <ManifestModelGet> PostManifestAsync(ManifestModel inModel, string sessionId, string RequestType)
        {
            ManifestModelGet outModel = null;

            try
            {
                string url     = string.Format(Configuration.PostManifestUrl, sessionId);
                string content = JsonConvert.SerializeObject(inModel);
                var    value   = await App.kegIDClient.ExecuteServiceCall <KegIDResponse>(url, HttpMethodType.Send, content, RequestType : RequestType);

                outModel = !string.IsNullOrEmpty(value.Response) ? App.kegIDClient.DeserializeObject <ManifestModelGet>(value.Response) : new ManifestModelGet();
                if (outModel != null)
                {
                    outModel.Response = new KegIDResponse
                    {
                        StatusCode = value.StatusCode
                    };
                }
            }
            catch (System.Exception)
            {
            }
            return(outModel);
        }
        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();
            }
        }