Esempio n. 1
0
    public Task UpdateExpenseAsync(Expense expense)
    {
      if (expenseTable == null)
        return Task.Factory.StartNew(() => { expense.UserId = UserId; });

      return expenseTable.UpdateAsync(expense);
    }
Esempio n. 2
0
 public async Task Init(int id)
 {
   if (id >= 0)
     currentExpense = await expenseService.GetExpense(id);
   else
     currentExpense = null;
   Init();
 }
Esempio n. 3
0
    public Task UpdateExpenseAsync(Expense expense)
    {
      /*if (expenseTable == null)
      {
        expense.UserId = UserId;
        return Task.FromResult<object>(null);
      }*/

      return expenseTable.UpdateAsync(expense);
    }
Esempio n. 4
0
 public Task InsertExpenseAsync(Expense expense)
 {
   if (expenseTable == null)
   {
     expense.UserId = UserId;
     return Task.FromResult<object>(null);
   }
   
   return expenseTable.InsertAsync(expense);
 }
Esempio n. 5
0
 public void SyncProperties(Expense expense)
 {
   this.AzureId = expense.AzureId;
   this.Billable = expense.Billable;
   this.Category = expense.Category;
   this.Due = expense.Due;
   this.IsVisible = expense.IsVisible;
   this.Name = expense.Name;
   this.Notes = expense.Notes;
   this.Total = expense.Total;
   this.UserId = expense.UserId;
 }
    public ExpenseViewController(Expense expense) : base(UITableViewStyle.Plain, null, true)
    {
      this.expense = expense;
      dialog = ServiceContainer.Resolve<IMessageDialog>();
      viewModel = ServiceContainer.Resolve<ExpenseViewModel>();
      viewModel.Init(this.expense);

      viewModel.IsBusyChanged = (busy) =>
      {
        if (busy)
          BTProgressHUD.Show("Saving...");
        else
          BTProgressHUD.Dismiss();
      };
    }
        public void TestGetExpenses()
        {
            var expenseService = ServiceContainer.Resolve<IExpenseService>();
            var expense = new Expense();
            expenseService.SaveExpense(expense);

            var viewModel = ServiceContainer.Resolve<ExpensesViewModel>();
            var task = viewModel.ExecuteLoadExpensesCommand();
            do
            {

            } while (!task.IsCompleted);

            Assert.IsTrue(viewModel.Expenses.Count == 1);
        }
        public void TestDeleteExpense()
        {
            var expenseService = ServiceContainer.Resolve<IExpenseService>();
            var expense = new Expense();
            expenseService.SaveExpense(expense);

            var viewModel = ServiceContainer.Resolve<ExpensesViewModel>();
            var task = viewModel.ExecuteDeleteExpenseCommand(expense);

            do
            {

            } while (!task.IsCompleted);

            Assert.IsTrue(!viewModel.Expenses.Any());
        }
Esempio n. 9
0
 public void Init(Expense expense)
 {
   currentExpense = expense;
   Init();
 }
Esempio n. 10
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.SaveExpense(currentExpense);
        ServiceContainer.Resolve<ExpensesViewModel>().NeedsUpdate = true;
        CanNavigate = true;
      }
      catch (Exception ex)
      {
        
        
      }
      finally
      {
        IsBusy = false;
      }
    }
Esempio n. 11
0
    public async Task ExecuteDeleteExpenseCommand(Expense exp)
    {
      if (IsBusy)
        return;

      IsBusy = true;
      try
      {

        await expenseService.DeleteExpense(exp.Id);
        Expenses.Remove(Expenses.FirstOrDefault(ex => ex.Id == exp.Id));


      }
      catch (Exception ex)
      {
        Debug.WriteLine("Unable to delete expenses");
      }
      finally
      {
        IsBusy = false;
      }
    }
Esempio n. 12
0
 public Expense(Expense expense)
 {
   SyncProperties(expense);
 }
Esempio n. 13
0
 public Expense(Expense expense)
 {
     SyncProperties(expense);
 }