private void DeleteSelected_Click(object sender, RoutedEventArgs e) { List <MeasurementLogEntry> entries = new List <MeasurementLogEntry>(); ProgressBar.Visibility = Visibility.Visible; foreach (MeasurementLogEntry entry in context.MeasurementLogEntries) { CheckBox selectItem = null; MeasurementLogGrid.SelectedItem = entry; selectItem = MeasurementLogGrid.Columns[MeasurementLogGrid.Columns.Count - 1].GetCellContent(MeasurementLogGrid.SelectedItem) as CheckBox; if (selectItem != null) { if (selectItem.IsChecked == true) { entries.Add(entry); } } } foreach (MeasurementLogEntry entry in entries) { context.MeasurementLogEntries.Remove(entry); } context.SubmitChanges((EntriesRemoved) => { ProgressBar.Visibility = Visibility.Collapsed; MeasurementData.Load(); }, null); }
private void CreateMeasurementLogEntry(FitnessTrackerPlus.Web.Data.Measurement measurement) { MeasurementLogEntry entry = new MeasurementLogEntry(); // Setup new measurement log entry with selected date, measurement and current user IEnumerator units = measurement.MeasurementsUnits.GetEnumerator(); units.MoveNext(); entry.measurement_id = measurement.id; entry.entry_date = Globals.SelectedDate; entry.user_id = Globals.CurrentUser.id; entry.unit_id = (units.Current as MeasurementsUnits).unit_id; context.MeasurementLogEntries.Add(entry); context.SubmitChanges((ChangesSubmitted) => { if (!ChangesSubmitted.HasError) { MeasurementData.Load(); } }, null); }