protected override void SetContextData() { repo = new MetersRepo(testCtx); var f = new Faker <Meters>() .RuleFor(r => r.Corporation, v => v.Company.CompanyName()) .RuleFor(r => r.CurrentlyActive, v => v.Random.Bool()) .RuleFor(r => r.ExternalId, v => v.Lorem.Word()) .RuleFor(r => r.InsuletMarket, v => v.Random.Bool()) .RuleFor(r => r.MeterClass, v => v.Lorem.Word()) .RuleFor(r => r.MeterDelphiIndex, v => v.Random.Int(1, 76)) .RuleFor(r => r.MeterDelphiName, v => v.Lorem.Word()) .RuleFor(r => r.MeterImageName, v => v.Lorem.Word()) .RuleFor(r => r.MeterManufacturer, v => v.Company.CompanyName()) .RuleFor(r => r.MeterModel, v => v.Lorem.Word()) .RuleFor(r => r.MeterName, v => v.Lorem.Word()) .RuleFor(r => r.MeterPid, v => v.Lorem.Word()) .RuleFor(r => r.MeterVid, v => v.Lorem.Word()); var gen = f.Generate(3).OrderBy(o => o.Id).ToList(); testCtx.Meters.AddRange(gen); FakeCollection.AddRange(gen); int added = testCtx.SaveChanges(); }
public MetersWindow(Realty realty) { this.realty = realty; InitializeComponent(); ChooseImage(); using (MetersRepo metersRepo = new MetersRepo()) { foreach (long meterId in realty.AvailableMeters) { MetersList.Items.Add(new MeterInfo(metersRepo.GetMeterInfo(meterId))); } } }
private void ApplyBtn_Click(object sender, RoutedEventArgs e) { using (MetersRepo metersRepo = new MetersRepo()) { try { metersRepo.UpdateCurrentReadings(meter.Id, Convert.ToDecimal(ReadingsTb.Text)); } catch (Exception exc) { MessageBox.Show(exc.ToString()); } } }