public static UnitTypeClientModel ToClientModel(this UnitTypeEntity entity)
 {
     return(new UnitTypeClientModel
     {
         Id = entity.Id,
         DisplayName = entity.DisplayName,
         BaseUnit = entity.BaseUnit.ToClientModel(),
         Units = entity.Units.ToClientModels()
     });
 }
示例#2
0
        private UnitTypeConversionGraphClientModel GetUnitTypeConversionGraph(UnitTypeEntity unitType)
        {
            var conversionsGraph = new Dictionary <string, Dictionary <string, double> >();

            var conversions = _conversionDal.GetConversions(unitType.Id);

            foreach (var conversion in conversions)
            {
                AddConversion(conversionsGraph, conversion.FromUnit, conversion.ToUnit, conversion.Multiplier);
                AddConversion(conversionsGraph, conversion.ToUnit, conversion.FromUnit, 1.0 / conversion.Multiplier);
            }

            return(new UnitTypeConversionGraphClientModel
            {
                UnitType = unitType.ToClientModel(),
                ConversionGraph = conversionsGraph
            });
        }