public Task <int> SaveItemAsync(Debt item) { if (item.ID != 0) { return(database.UpdateAsync(item)); } else { return(database.InsertAsync(item)); } }
private void Button_Click_7(object sender, RoutedEventArgs e) { var dbConnection = DatabaseDebt; DebtDatabase produktDatabase = DatabaseDebt; Debt item = new Debt(); string name = nameDebt.Text; string price = newDebt.Text; string date = dateDebt.Text; int x = Int32.Parse(price); item.Price = x; item.Date = date; item.Name = name; DatabaseDebt.SaveItemAsync(item); debtCol.Add(item); var itemsFromDb = DatabaseDebt.GetItemsAsync().Result; debtList.ItemsSource = debtCol; int overduePrice = 0; foreach (var data in itemsFromDb) { int result = DateTime.Compare(today.Date, Convert.ToDateTime(data.Date)); //debtCount.Text = "Dluh celkem: " + data.Price; if (result >= 1) { overduePrice += data.Price; debtDue.Text = "Dluh přesčas: " + overduePrice; } } }
public Task <int> DeleteItemAsync(Debt item) { return(database.DeleteAsync(item)); }