async void OnComfirmClicked(object sender, System.EventArgs e) { SQLiteAsyncConnection _connection = DependencyService.Get <ISQLiteDb>().GetConnection(); if (IsAddValid()) { diet.SetTime(); await _connection.UpdateAsync(diet); await Navigation.PopToRootAsync(); } else { message.BackgroundColor = Color.Red; message.Text = "please enter description and enter numbers in calories"; } }
async public void OnDoneClicked(object sender, EventArgs e) { var addSucceed = IsAddValid(); if (addSucceed) { _connection = DependencyService.Get <ISQLiteDb>().GetConnection(); await _connection.CreateTableAsync <DietRecord>(); //var dietRecords = await _connection.Table<DietRecord>().ToListAsync(); //_dietRecords = new ObservableCollection<DietRecord>(dietRecords); //dietRecordListView.ItemsSource = _dietRecords; var newDiet = new DietRecord { Description = descriptionEditor.Text, Calories = Convert.ToInt32(calEntry.Text), Image = imagesPath[0] + ";" + imagesPath[1] + ";" + imagesPath[2], Date = datePicker.Date, Time = timePicker.Time, UserId = App.user.UserId }; newDiet.SetTime(); await _connection.InsertAsync(newDiet); //_dietRecords.Add(newDiet); await Navigation.PopToRootAsync(); } else { message.Text = "please enter description and enter numbers in calories"; message.BackgroundColor = Color.Red; } }