public void Add() { GetError("BeginHour", "EndHour", "Limit", "City"); if (Errors.Count < 1) { var limit = new MeasurementLimit(BeginHour, EndHour, Limit, City); MeasurementLimit.AllMeasurementLimits.Insert(0, limit); MeasurementLimits.Clear(); foreach (var c in MeasurementLimit.AllMeasurementLimits) { MeasurementLimits.Add(c); } SelectedItem = limit; } else { StringBuilder sb = new StringBuilder(); foreach (var k in Errors.Keys) { sb.Append($"Ошибка в поле {k}: {Errors[k]};"); } Errors.Clear(); MessageBox.Show(sb.ToString()); } }
public void Find() { MeasurementLimits.Clear(); var list = MeasurementLimit.AllMeasurementLimits .Where(m => CityForFind == null || CityForFind.Id == AllCity.Id || m.City.Id == CityForFind.Id).ToList(); foreach (var m in list) { MeasurementLimits.Add(m); } SelectedItem = null; }