private void DoneButton_Clicked(object sender, EventArgs e) { if (CategoryPicker.SelectedIndex != -1) { var transaction = new TransactionDetail { Category = CategoryPicker.Items[CategoryPicker.SelectedIndex], Date = DateTimePicker.Date, Spent = double.Parse(AmountSpent.Value.ToString()), Name = Description.Text }; ((ExpenseViewModel)BindingContext).AddTransaction(transaction); TransactionPage.CanNotify = true; } Navigation.PopToRootAsync(); }
public void AddNewTransactions() { if (Device.RuntimePlatform == Device.macOS) { if (CategorySelected != null) { var transaction = new TransactionDetail { Category = CategorySelected.ToString(), Date = Date, Spent = SpentOn, Name = ExpenseDescription }; App.DataService.InsertTansaction(transaction); Transactions.Add(transaction); NavigationService.NavigatePopToRoot(); } } else { if (!String.IsNullOrEmpty(SingleTransaction.ExpenseDescription)) { var newTransaction = SingleTransaction; var transaction = new TransactionDetail { Category = newTransaction.Category.ToString(), Date = newTransaction.Date, Spent = newTransaction.Spent, Name = newTransaction.ExpenseDescription }; App.DataService.InsertTansaction(transaction); Transactions.Add(transaction); NavigationService.NavigatePopToRoot(); } } }
internal void InsertTansaction(TransactionDetail transaction) { db.Insert(transaction); }
/// <summary> /// Inserts the newly added transaction to DataBase and Transactions /// </summary> /// <param name="transaction"></param> public void AddTransaction(TransactionDetail transaction) { App.DataService.InsertTansaction(transaction); Transactions.Add(transaction); }