Пример #1
0
        private async void cmdOk_Clicked(object sender, EventArgs e)
        {
            try
            {
                gridProgress.IsVisible = true;
                InventoryGroup group = (pickGroup.SelectedItem as InventoryGroup);
                InventoryItem.InventoryGroupIdRef = group.InventoryGroupId;
                InventoryItem ii = new InventoryItem()
                {
                    Name                = InventoryItem.Name,
                    Description         = InventoryItem.Description,
                    Barcode             = InventoryItem.Barcode,
                    InventoryGroupIdRef = InventoryItem.InventoryGroupIdRef,
                    Price               = Validate.AmountToCents(InventoryItem.Price)
                };
                XServerApiClient client = SessionSingleton.GenXServerApiClient();
                using (SessionSingleton.HttpClient)
                {
                    switch (updateType)
                    {
                    case UpdateType.Add:
                        int id = await client.StoreInventoryitemPostAsync(ii.ToJsonString());

                        InventoryItem.InventoryItemId = id;
                        break;

                    case UpdateType.Update:
                        InventoryItem.InventoryGroupIdRef = group.InventoryGroupId;
                        ii.InventoryItemId = InventoryItem.InventoryItemId;
                        await client.StoreInventoryitemPutAsync(ii.ToJsonString());

                        break;
                    }
                }
                IsCancelled = false;
                ClosePage();
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Error", ex.Message, "OK");
            }
            finally
            {
                gridProgress.IsVisible = false;
            }
        }