public Task <int> SaveReportAsync(NewReportItem newItem) { if (newItem.ID != 0) { return(_database.UpdateAsync(newItem)); } else { return(_database.InsertAsync(newItem)); } }
private async void ImageButton_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(ent_itemname.Text)) { await DisplayAlert("", "項目名を入力してください。", "はい"); } else if (radio_category.SelectedItem == null) { await DisplayAlert("", "項目のカテゴリを選択してください。", "はい"); } else { App.newItem = ent_itemname.Text; newitem_index = Preferences.Get("newitem_id", 0); newitem_index++; NewReportItem newItem = new NewReportItem(); newItem.item_index = newitem_index.ToString(); newItem.item_name = ent_itemname.Text; newItem.item_type = radio_category.SelectedItem.ToString(); await App.newReportItem.SaveReportAsync(newItem); Global.reportItems.Add(new ReportItems { dynamic_index = newitem_index, fee_name = ent_itemname.Text, calculate_type = newItem.item_type, fee_value = new string[12] }); MessagingCenter.Send <App>((App)Application.Current, "AddNewItem"); await PopupNavigation.Instance.PopAsync(); } }
public Task <int> DeleteReportAsync(NewReportItem newItem) { return(_database.DeleteAsync(newItem)); }