Esempio n. 1
0
        public OrderItemsViewModel(IOrderItemService orderItemService, IOrderService orderService, ICommonServices commonServices) : base(commonServices)
        {
            OrderItemService = orderItemService;

            OrderItemList    = new OrderItemListViewModel(OrderItemService, commonServices);
            OrderItemDetails = new OrderItemDetailsViewModel(OrderItemService, commonServices);
        }
Esempio n. 2
0
        /*
         *  Handle external messages
         ****************************************************************/
        private async void OnDetailsMessage(OrderItemDetailsViewModel sender, string message, OrderItemModel changed)
        {
            var current = Item;

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

                        break;

                    case "ItemDeleted":
                        await OnItemDeletedExternally();

                        break;
                    }
                }
            }
        }