Exemplo n.º 1
0
        public async Task ExecuteSaveExpenseCommand()
        {
            if (IsBusy)
            {
                return;
            }
            if (currentExpense == null)
            {
                currentExpense = new Expense();
            }

            currentExpense.Billable = Billable;
            currentExpense.Category = Category;
            currentExpense.Due      = Due.ToUniversalTime();
            currentExpense.Name     = Name;
            currentExpense.Notes    = Notes;
            currentExpense.Total    = Total;
            try
            {
                await expenseService.SaveExpense(currentExpense);

                ServiceContainer.Resolve <ExpensesViewModel>().NeedsUpdate = true;
            }
            catch (Exception)
            {
                Debug.WriteLine("Unable to save expense.");
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        public async Task ExecuteSaveExpenseCommand()
        {
            if (IsBusy)
            {
                return;
            }

            CanNavigate = false;
            if (currentExpense == null)
            {
                currentExpense = new Expense();
            }

            currentExpense.Billable = Billable;
            currentExpense.Category = Category;
            currentExpense.Due      = Due.ToUniversalTime();
            currentExpense.Name     = Name;
            currentExpense.Notes    = Notes;
            currentExpense.Total    = Total;
            try
            {
                IsBusy = true;
                await expenseService.SaveExpenseAsync(currentExpense);

                await expenseService.SyncExpensesAsync();

                ServiceContainer.Resolve <ExpensesViewModel>().NeedsUpdate = true;
                CanNavigate = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsBusy = false;
            }
        }