Beispiel #1
0
        private async Task OnSaveInventory()
        {
            bool result = false;

            try
            {
                if (NewInventory)
                {
                    result = await inventoryRepo.AddInventoryAsync(Inventory);
                }
                else
                {
                    result = await inventoryRepo.UpdateInventoryAsync(Inventory);
                }
            }
            catch (Exception e)
            {
                alertService.Show("Błąd", $"W trakcie zapisu towaru wystąpił błąd. Szczegóły:{e.InnerException.Message}", "Zamknij");
            }

            await Page.Navigation.PopAsync();

            if (result && ViewModel is InventListViewModel)
            {
                (ViewModel as InventListViewModel).RefreshListCommand.Execute(null);
            }
            else if (NewInventory)
            {
                alertService.Show("Dodano nowy towar", $"Dodano nowy towar: {Inventory.Name}", "OK");
            }
        }
Beispiel #2
0
        public async Task <int> RunCommand(CreateOptions opts)
        {
            try
            {
                await _inventoryRepository.AddInventoryAsync(opts.Inventory);

                _gui.WriteSuccess($"Created inventory {opts.Inventory}");
                return(0);
            }
            catch (Exception e)
            {
                _gui.WriteError($"Failed to create {opts.Inventory} - { e }");
                return(1);
            }
        }
Beispiel #3
0
 public async Task ExecuteAsync(Inventory inventory)
 {
     await inventoryRepository.AddInventoryAsync(inventory);
 }