Exemplo n.º 1
0
        private async void SubmitOrder_OnClick(object sender, RoutedEventArgs e)
        {
            ProcessingRing.IsActive = true;
            SubmitOrder.IsEnabled = false;

            Exception exception = null;
            bool submitted = false;
            try
            {
                var repository = ServiceLocator.Get<CartRepository>();

                var user = await Authenticate();
                if (user != null)
                {

                    Cart.UserId = user.UserId;
                    Cart.HardwareId = HardwareIdentificationHelpers.GetHardwareId();
                    await repository.SubmitCart(Cart);

                    var eventAggregator = ServiceLocator.Get<IEventAggregator>();
                    eventAggregator.Publish(new OrderPlacedEvent(Cart));

                    Cart = new Cart();
                    submitted = true;
                }

            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                var dialog = new MessageDialog(exception.Message);
                await dialog.ShowAsync();
            }
            else if (submitted)
            {
                Frame.Navigate(typeof(GroupedItemsPage), "AllCategories");
            }

            ProcessingRing.IsActive = false;
            SubmitOrder.IsEnabled = true;
        }
Exemplo n.º 2
0
 public CartItemAddedEvent(Cart cart)
 {
     Cart = cart;
 }
Exemplo n.º 3
0
 public OrderPlacedEvent(Cart cart)
 {
     Cart = cart;
 }