예제 #1
0
        /*
         *  Handle external messages
         ****************************************************************/
        private async void OnDetailsMessage(OrderDetailsViewModel sender, string message, OrderModel changed)
        {
            var current = Item;

            if (current != null)
            {
                if (changed != null && changed.OrderID == current?.OrderID)
                {
                    switch (message)
                    {
                    case "ItemChanged":
                        await ContextService.RunAsync(async() =>
                        {
                            try
                            {
                                var item = await OrderService.GetOrderAsync(current.OrderID);
                                item     = item ?? new OrderModel {
                                    OrderID = current.OrderID, IsEmpty = true
                                };
                                current.Merge(item);
                                current.NotifyChanges();
                                NotifyPropertyChanged(nameof(Title));
                                if (IsEditMode)
                                {
                                    StatusMessage("WARNING: This order has been modified externally");
                                }
                            }
                            catch (Exception ex)
                            {
                                LogException("Order", "Handle Changes", ex);
                            }
                        });

                        break;

                    case "ItemDeleted":
                        await OnItemDeletedExternally();

                        break;
                    }
                }
            }
        }
 public OrderDetailsWithItemsViewModel(IOrderService orderService, IOrderItemService orderItemService, ICommonServices commonServices) : base(commonServices)
 {
     OrderDetails  = new OrderDetailsViewModel(orderService, commonServices);
     OrderItemList = new OrderItemListViewModel(orderItemService, commonServices);
 }