Пример #1
0
 public SystemsOfUnitsRepository(QuantityDbContext c) : base(c, c?.SystemsOfUnits)
 {
 }
Пример #2
0
 public MeasuresRepository(QuantityDbContext c) : base(c, c.Measures)
 {
 }
Пример #3
0
 public UnitFactorsRepository(QuantityDbContext c) : base(c, c?.UnitFactors)
 {
 }
Пример #4
0
 public static void Initialize(QuantityDbContext db)
 {
     InitializeMeasures(db);
     InitializeUnits(db);
 }
Пример #5
0
 public MeasureTermsRepository(QuantityDbContext c) : base(c, c?.MeasureTerms)
 {
 }
Пример #6
0
 public UnitTermsRepository(QuantityDbContext c) : base(c, c?.UnitTerms)
 {
 }
Пример #7
0
        private static void addUnitFactors(List <Core.Units.Data> units, string siSystemId, QuantityDbContext db)
        {
            foreach (var d in units)
            {
                if (Math.Abs(d.Factor) < double.Epsilon)
                {
                    continue;
                }
                var o = db.UnitFactors.FirstOrDefaultAsync(
                    m => m.SystemOfUnitsId == siSystemId && m.UnitId == d.Id).GetAwaiter().GetResult();

                if (!(o is null))
                {
                    continue;
                }
                db.UnitFactors.Add(
                    new UnitFactorData()
                {
                    SystemOfUnitsId = siSystemId,
                    UnitId          = d.Id,
                    Factor          = d.Factor
                });
            }
        }
Пример #8
0
 private static void initialize(Core.Units.Data measure, List <Core.Units.Data> units, QuantityDbContext db)
 {
     addMeasure(measure, db);
     addTerms(measure, db.MeasureTerms);
     addUnits(units, measure.Id, db);
     addTerms(units, db);
     addUnitFactors(units, SystemOfUnits.SiSystemId, db);
     db.SaveChanges();
 }
Пример #9
0
 private static void addUnits(IEnumerable <Core.Units.Data> units, string measureId, QuantityDbContext db)
 {
     foreach (var d in from d in units
              let o = getItem(db.Units, d.Id)
                      where o is null
                      select d)
     {
         db.Units.Add(
             new UnitData {
             MeasureId  = measureId,
             Id         = d.Id,
             Code       = d.Code,
             Name       = d.Name,
             Definition = d.Definition
         });
     }
 }