Beispiel #1
0
        public static string GetRoundedWeight(decimal weight, bool withSufix, WeightPrefix weightPrefix, bool shortToken = false)
        {
            weight = GetConvertedWeight(weight, weightPrefix);



            var sufix = string.Empty;

            if (withSufix)
            {
                sufix = " " + weightPrefix.ToString();
                if (shortToken)
                {
                    sufix = " " + GetShortToken(weightPrefix);
                }
            }
            int value = Convert.ToInt32(@Math.Round(weight, 0));

            if (value > 0)
            {
                return(value + sufix);
            }
            var value2 = Math.Round(weight, 2);

            if (value2 > Convert.ToDecimal(0))
            {
                if (value2 > Convert.ToDecimal(0))
                {
                    var sv = value2.ToString();
                    if (sv.EndsWith("0"))
                    {
                        sv = sv.Remove(sv.Length - 1);
                    }
                    return(sv + sufix);
                }
            }
            if (weight > Convert.ToDecimal(0))
            {
                return(Convert.ToDecimal(0.01).ToString() + sufix);
            }

            return("0" + sufix);
        }
Beispiel #2
0
 public void Update(string name, WeightPrefix weightPrefix, bool isPublic)
 {
     Entity.Name         = name;
     Entity.WeightPrefix = weightPrefix.ToString();
     Entity.IsPublic     = isPublic;
 }