public void addWeightItem(weightItem newWeightItem) { //add a to-do list item to the data context allWeightDB.weightList.InsertOnSubmit(newWeightItem); //submit changes to database allWeightDB.SubmitChanges(); //add weight into the weight collection AllWeightItems.Add(newWeightItem); }
public void deleteWeightItem(weightItem weightItemtoBeDeleted) { //remove weight item from weight collection AllWeightItems.Remove(weightItemtoBeDeleted); //remove weight item from data context allWeightDB.weightList.DeleteOnSubmit(weightItemtoBeDeleted); //save the changes to the database allWeightDB.SubmitChanges(); }
private void appbarSubmitButton_Click(object sender, EventArgs e) { //confirm there is some text in the text box if (weightBox.Text.Length > 0) { weightItem item = new weightItem { Weight = weightBox.Text, DateofMeasurement = newWeightDate.Value.Value.ToShortDateString() }; //add the item to the viewmodel App.ViewModel.addWeightItem(item); //return to the main page if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } }