Ejemplo n.º 1
0
        public UomWeight FindForEnum(UomWeightENUM theEnum)
        {
            if (theEnum == UomWeightENUM.Unknown)
            {
                return(null);
            }

            string name = Enum.GetName(theEnum.GetType(), theEnum);

            return(FindForName(name.ToSentence()));
        }
Ejemplo n.º 2
0
        public void InitializeFromEnumAndSave()
        {
            UomWeightENUM c = UomWeightENUM.Unknown;

            //this will create customer categories for the Enums
            //var listOfEnums = c.ToTitleSentanceList();
            var listOfEnums = Enum.GetNames(c.GetType()).ToList();

            listOfEnums.Remove(UomWeightENUM.Unknown.ToString());


            foreach (var item in listOfEnums)
            {
                UomWeight uomWeight = Factory();
                uomWeight.Name = item.ToSentence().ToTitleCase();
                uomWeight.MetaData.IsAutoCreated = true;

                switch (item.ToLower())
                {
                case "gm":
                    uomWeight.Multiplier = 0.001;
                    break;

                case "kg":
                    uomWeight.Multiplier = 1;
                    break;

                case "lb":
                    uomWeight.Multiplier = 0.453592;
                    break;

                case "oz":
                    uomWeight.Multiplier = 0.0283495;
                    break;
                }
                uomWeight.MetaData.Comment = "Initialized automatically for KG on " + DateTime.UtcNow;

                try
                {
                    Create(uomWeight);
                }
                catch (ErrorHandlerLibrary.ExceptionsNS.NoDuplicateException)
                {
                }
            }
            Save();
        }