Beispiel #1
0
		private void DoAddCommand()
		{
			float man, woman;
			try
			{
				var manStrVal = string.IsNullOrEmpty(ManAmount) ? "0" : ManAmount;
				var womanStrVal = string.IsNullOrEmpty(WomanAmount) ? "0" : WomanAmount;

				man = float.Parse(manStrVal);
				woman = float.Parse(womanStrVal);
			}
			catch (Exception ex)
			{// Show a popup to inform not valid
				Debug.WriteLine("Error during parse when adding new expense : " + ex.Message);
				return;
			}

			if (man <= 0 && woman <= 0)
				return;

			var newExp = new Expense
			{
				AddedOn = NewExpenseDate,
				ManExpense = man,
				WomanExpense = woman,
				Details = NewExpenseDetails
			};

			MessagingCenter.Send<AddViewModel, Expense>(this, "AddExpense", newExp);

			ClearAddProperties();
			Xamarin.Forms.Device.BeginInvokeOnMainThread(() => _navigation.PopToRootAsync(true));
		}
        public async Task AddExpenseAsync(Expense expense)
        {
			if (!_initialized)
				Init();
			
            await Connection.InsertAsync(expense).ConfigureAwait(false);
        }
		public ExpenseItemViewModel(Expense expense)
		{
			Expense = expense;
		}
Beispiel #4
0
		public async Task AddExpenseAsync(Expense expense)
        {
			await _expenseRepository.AddExpenseAsync(expense).ConfigureAwait(false);
        }