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

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

      return expenseTable.UpdateAsync(expense);
    }
Beispiel #4
0
 public Task InsertExpenseAsync(Expense expense)
 {
   if (expenseTable == null)
   {
     expense.UserId = UserId;
     return Task.FromResult<object>(null);
   }
   
   return expenseTable.InsertAsync(expense);
 }
Beispiel #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());
        }
Beispiel #9
0
 public void Init(Expense expense)
 {
   currentExpense = expense;
   Init();
 }
Beispiel #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;
      }
    }
    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;
      }
    }
Beispiel #12
0
 public Expense(Expense expense)
 {
   SyncProperties(expense);
 }
 public Expense(Expense expense)
 {
     SyncProperties(expense);
 }