Esempio n. 1
0
        private void OnSubmitOrder()
        {
            if (_CurrentOrder.CustomerId != Guid.Empty && _CurrentOrder.OrderItems.Count > 0)
            {
                //PizzaServiceClient proxy = new PizzaServiceClient("NetTcpBinding_IZzaService");
                PizzaProxy proxy = new PizzaProxy("NetTcpBinding_IPizzaService");

                try
                {
                    proxy.SubmitOrder(_CurrentOrder);
                    CurrentOrder               = new Order();
                    CurrentOrder.OrderDate     = DateTime.Now;
                    CurrentOrder.OrderStatusId = 1;
                    Items = new ObservableCollection <OrderItemModel>();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error saving order, please try again later.");
                    // Log it
                }
                finally
                {
                    proxy.Close();
                }
            }
            else
            {
                MessageBox.Show("You must select a customer and add order items to submit an order");
            }
        }
Esempio n. 2
0
        private async void LoadProductsAndCustomers()
        {
            // Use auto generated proxy to make service calls
            //PizzaServiceClient proxy = new PizzaServiceClient("NetTcpBinding_IPizzaService");

            // Use manually created proxy to make service calls
            PizzaProxy proxy = new PizzaProxy("NetTcpBinding_IPizzaService");

            try
            {
                Products = await proxy.GetProductsAsync();

                Customers = await proxy.GetCustomersAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to load server data. " + ex.Message);
            }
            finally
            {
                proxy.Close();
            }
        }