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; }
public CartItemAddedEvent(Cart cart) { Cart = cart; }
public OrderPlacedEvent(Cart cart) { Cart = cart; }