private async void bCreate_Click(object sender, RoutedEventArgs e) { int productId = (cProduct.SelectedItem as Tuple<int, string>).Item1; int supplierId = (cSupplier.SelectedItem as Tuple<int, string>).Item1; bCreate.IsEnabled = false; txtQuantity.IsEnabled = false; cSupplier.IsEnabled = false; cProduct.IsEnabled = false; ISuppliersService supplierService = new SuppliersServiceClient(); await supplierService.OrderProductAsync(new OrderProductModel { ProductCode = productId, Supplier = supplierId, Quantity = int.Parse(txtQuantity.Text) }); bCreate.IsEnabled = true; txtQuantity.IsEnabled = true; cSupplier.IsEnabled = true; cProduct.IsEnabled = true; cSupplier.SelectedIndex = -1; txtQuantity.Text = string.Empty; (DataContext as PlaceOrderViewModel).Products = new List<Tuple<int, string>>(); }
private async void bObtainList_Click(object sender, RoutedEventArgs e) { SuppliersServiceClient supplierServiceClient = new SuppliersServiceClient(); IEnumerable<SupplierModel> suppliers = await supplierServiceClient.AllSuppliersAsync(); (DataContext as SupplierListViewModel).DataSource = suppliers.Select(c => new SupplierViewModel { Number = c.Id, Name = c.Name, Address = c.Address }); }
private async void RefreshSuppliers() { SuppliersServiceClient supplierServiceClient = new SuppliersServiceClient(); IEnumerable<SupplierModel> suppliers = await supplierServiceClient.AllSuppliersAsync(); (DataContext as PlaceOrderViewModel).Suppliers = suppliers.Select(s => Tuple.Create(s.Id, s.Name)); }