예제 #1
0
        public AddNewItemViewModel(INavigation navigation)
        {
            _navigation         = navigation;
            _inventoryValidator = new InventoryValidator();
            _item          = new Inventory();
            _inventoryRepo = new InventoryRepo();

            AddItemCommand = new Command(async() => await AddItem());
        }
예제 #2
0
        public ReduceItemStockViewModel(INavigation navigation)
        {
            _navigation         = navigation;
            _inventoryValidator = new InventoryValidator();
            _item          = new Inventory();
            _inventoryRepo = new InventoryRepo();

            RemoveItemStockCommand = new Command(async() => await RemoveItemStock(SelectedItem, ValueAdjuster));

            FetchInventory();
        }
예제 #3
0
        public IncreaseItemStockViewModel(INavigation navigation)
        {
            _navigation         = navigation;
            _inventoryValidator = new InventoryValidator();
            _item          = new Inventory();
            _inventoryRepo = new InventoryRepo();

            IncreaseItemStockCommand = new Command(async() => await IncreaseItemStock(SelectedItem, ValueAdjuster, NewPrice, NewLocation));

            FetchInventory();
        }
예제 #4
0
        public ModifyItemViewModel(INavigation navigation, int selectedItemID)
        {
            _navigation         = navigation;
            _inventoryValidator = new InventoryValidator();
            _item          = new Inventory();
            _item.Id       = selectedItemID;
            _inventoryRepo = new InventoryRepo();

            UpdateItemCommand = new Command(async() => await UpdateItem());

            FetchItem();
        }
예제 #5
0
 private void BtnAdd(object sender, RoutedEventArgs e)
 {
     if (InventoryValidator.IsValid(this.viewModel))
     {
         DbManager.Instance.AddAuthor(this.viewModel);
         MessageBox.Show("Author added!");
         this.NavigationService?.GoBack();
     }
     else
     {
         MessageBox.Show("Couldn't add the user. Make sure you've typed in all details!");
     }
 }
예제 #6
0
        public void SaveData()
        {
            InventoryModel currentData = new InventoryModel();

            CollectDetails(currentData);
            InventoryValidator validator = new InventoryValidator();
            ValidationResult   result    = validator.Validate(currentData);

            if (result.IsValid == false)
            {
                string errorMessage = (String.Join(Environment.NewLine + "   • ",
                                                   result.Errors.Select(error => error.ErrorMessage)));
                universalHelper.MessageDialog("Saving of data failed!", "   • " + errorMessage);
                return;
            }
            else
            {
                helper.SaveItem(currentData);
            }
        }