public void RemoveMeasurements(Measurement toDelete, DataRepository dr) { List<Measurement> toDeleteList = getToDeleteList(toDelete, dr); MeteoStationDBContext currentContext = dr.GetCurrentDBContext(); var pressureListToDelete = from p in dr.GetPressures() where p.Id == toDeleteList[0].Id select p; Pressure pressureToDelete = pressureListToDelete.First(); var temperatureListToDelete = from p in dr.GetTemperatures() where p.Id == toDeleteList[0].Id select p; Temperature temperatureToDelete = temperatureListToDelete.First(); var wetnessListToDelete = from p in dr.GetWetneses() where p.Id == toDeleteList[0].Id select p; Wetness wetnessToDelete = wetnessListToDelete.First(); currentContext.Temperature.Remove(temperatureToDelete); currentContext.Pressure.Remove(pressureToDelete); currentContext.Wetness.Remove(wetnessToDelete); currentContext.SaveChanges(); }
private void Cisnienie() { SetUp(this.Cis); DataRepository dr = new DataRepository(); if (dataKoncowa.ToString() != "01.01.0001 00:00:00" && dataPoczatkowa.ToString() != "01.01.0001 00:00:00") { var q = from a in dr.GetPressures() where a.MeteoStationOfMeasurement.Name == Chart.Okno.NazwyStacjiBox.Text && (a.DateOfMeasuement >= Chart.Okno.pierwszaData && a.DateOfMeasuement <= Chart.Okno.ostatniaData) select new { a.DateOfMeasuement, a.Value }; foreach (var item in q.OrderBy(x => x.DateOfMeasuement.Date)) { this.pomiaryC.Add(new Wetness { DateOfMeasuement = item.DateOfMeasuement, Value = item.Value }); this.LineCis.Points.Add(new DataPoint(DateTimeAxis.ToDouble(item.DateOfMeasuement.Date), item.Value)); } } else { var q = from a in dr.GetPressures() where a.MeteoStationOfMeasurement.Name == Chart.Okno.NazwyStacjiBox.Text select new { a.DateOfMeasuement, a.Value }; foreach (var item in q.OrderBy(x => x.DateOfMeasuement.Date)) { this.pomiaryC.Add(new Wetness { DateOfMeasuement = item.DateOfMeasuement, Value = item.Value }); this.LineCis.Points.Add(new DataPoint(DateTimeAxis.ToDouble(item.DateOfMeasuement.Date), item.Value)); } } this.Cis.Series.Add(LineCis); WypelnijListyZinterpolowanymiDanymi(pomiaryC, 0.1, Cis, AproCis); OnPropertyChanged("Cisnienie"); }