private async Task OnItemDeletedExternally()
 {
     await ContextService.RunAsync(() =>
     {
         CancelEdit();
         IsEnabled = false;
         StatusMessage("WARNING: This Taluk has been deleted externally");
     });
 }
Esempio n. 2
0
 private async void OnMessage(CustomerListViewModel viewModel, string message, object args)
 {
     if (viewModel == CustomerList && message == "ItemSelected")
     {
         await ContextService.RunAsync(() =>
         {
             OnItemSelected();
         });
     }
 }
Esempio n. 3
0
 private async void OnLogServiceMessage(ILogService logService, string message, AppLog log)
 {
     if (message == "LogAdded")
     {
         await ContextService.RunAsync(async() =>
         {
             await RefreshAsync();
         });
     }
 }
        private async void OnMessage(ViewModelBase sender, string message, object args)
        {
            switch (message)
            {
            case "NewItemSaved":
            case "ItemDeleted":
            case "ItemsDeleted":
            case "ItemRangesDeleted":
                await ContextService.RunAsync(async() =>
                {
                    await RefreshAsync();
                });

                break;
            }
        }
        /*
         *  Handle external messages
         ****************************************************************/
        private async void OnDetailsMessage(RoleDetailsViewModel sender, string message, RoleModel changed)
        {
            var current = Item;

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

                        break;

                    case "ItemDeleted":
                        await OnItemDeletedExternally();

                        break;
                    }
                }
            }
        }
Esempio n. 6
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;
                    }
                }
            }
        }