public ProductsCRUDViewModel(ProductsAndCost productsAndCost) { IsEnabled = false; CurrentProduct = new Product(); CurrentProductCost = new ProductCost(); DeleteProductCommand = new Command(async() => await DeleteProduct()); UpdateProductCommand = new Command(async() => await UpdateProduct()); SaveTappedCommand = new Command(async() => await SaveProduct()); ClearTappedCommand = new Command(async() => await ClearEdits(productsAndCost)); GetProductCommand = new Command(async() => await GetProduct(productsAndCost.CurrentProduct.ProductId)); GetProductCommand.Execute(new Command(async() => await GetProduct(productsAndCost.CurrentProduct.ProductId))); GetProductCostCommand = new Command(async() => await GetProductCost(productsAndCost.CurrentProductCost.ProductId)); GetProductCostCommand.Execute(new Command(async() => await GetProductCost(productsAndCost.CurrentProductCost.ProductId))); }
public ProductDetails(ProductsAndCost productsAndCost) { InitializeComponent(); BindingContext = new ProductsCRUDViewModel(productsAndCost); }
private async Task ClearEdits(ProductsAndCost productsAndCost) { CurrentProduct = await App.Database.GetProductAsync(productsAndCost.CurrentProduct.ProductId); CurrentProductCost = await App.Database.GetProductCostAsync(productsAndCost.CurrentProduct.ProductId); }