예제 #1
0
        private void TableAppSubscriber_NotifyOrderEndedEvent(object sender, EndOrderModel endOrderModel)
        {
            if (!IsSomethingOrdered)             //Z jakiegoś powodu wykonuje się dwukrotnie...
            {
                return;
            }

            var dispatcher      = Application.Current.Dispatcher;
            var endOrderMessage = endOrderModel.OrderCancelled
                                ? $"Your order was cancelled: {endOrderModel.OrderCancelledReason}"
                                : "Your order was processed successfully.";

            Action showMessageAction = () =>
            {
                ModernDialog.ShowMessage(endOrderMessage, "Order was closed", MessageBoxButton.OK, Application.Current.MainWindow);
            };

            if (dispatcher == null || dispatcher.CheckAccess())
            {
                showMessageAction.Invoke();
            }
            else
            {
                dispatcher.Invoke(showMessageAction);
            }

            IsSomethingOrdered = false;
            AddedElements.Clear();
            TotalPrice = 0;
        }
예제 #2
0
        private void TableAppSubscriberOnReservationOrderScheduledEvent(object sender, ReservationOrderScheduledModel reservationOrderScheduledModel)
        {
            //TODO: Przerwać trwające zamówienie
            IsSomethingOrdered = false;
            AddedElements.Clear();
            TotalPrice = 0;

            foreach (var menuItem in reservationOrderScheduledModel.MenuItems)
            {
                var item = Elements.FirstOrDefault(el => el.MenuItemId == menuItem.MenuItemId);

                for (int i = 0; i < menuItem.Quantities; i++)                 //TODO: Napisać to mądrzej...
                {
                    AddNewItem(item);
                }
            }

            ModernInputDialogMessageBoxResult result = null;

            Action showMessageAction = () =>
            {
                result = ModernInputDialog.ShowInputMessage("Unlock code:", "RESERVATION",
                                                            MessageBoxButton.OKCancel, Application.Current.MainWindow);
            };

            var dispatcher = Application.Current.Dispatcher;

            do
            {
                if (dispatcher == null || dispatcher.CheckAccess())
                {
                    showMessageAction.Invoke();
                }
                else
                {
                    dispatcher.Invoke(showMessageAction);
                }
            } while (result.MessageBoxResult != MessageBoxResult.OK ||
                     !result.Input.Equals(reservationOrderScheduledModel.UnlockCode));
        }