private void SubscribeForEvents()
        {
            MessagingCenter.Subscribe <NewExpensePage, Expense>(this, "AddExpense", async(obj, expense) =>
            {
                var newExpense = expense as Expense;
                Expenses.Add(newExpense);
                await AzureDataStore.AddItemAsync(newExpense);
            });

            MessagingCenter.Subscribe <FamilyAllExpensesPage, Expense>(this, "AddExpense2", async(obj, expense) =>
            {
                var newExpense = expense as Expense;
                Expenses.Insert(0, newExpense);
                await AzureDataStore.AddItemAsync(newExpense);
            });


            MessagingCenter.Subscribe <ExpenseService, UpdateStatusMessage>(this, "UpdateStatusMessage", (obj, args) =>
            {
                UpdateStatusMessage updateStatusMessage = args as UpdateStatusMessage;
                if (updateStatusMessage != null)
                {
                    if (updateStatusMessage.UpdateStatus == Enums.UpdateStatus.Completed)
                    {
                    }
                    StatusMessage = updateStatusMessage;
                }
            });
        }
Beispiel #2
0
 public TestViewModel()
 {
     ClickTest = new Command(async() =>
     {
         TodoItem item = new TodoItem()
         {
             Text = EntryText
         };
         bool res     = await testServices.AddItemAsync(item);
         ResponseType = (res ? 1 : 2);
         ResponseText = (res ? "Successful inserted" : "Failed to insert");
     });
 }