コード例 #1
0
ファイル: UomQtyDAL.cs プロジェクト: dovanduy/Library
        public UomQty FindForEnum(UomQtyENUM theEnum)
        {
            if (theEnum == UomQtyENUM.Unknown)
            {
                return(null);
            }

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

            return(FindForName(name.ToSentence()));
        }
コード例 #2
0
ファイル: UomQtyDAL.cs プロジェクト: dovanduy/Library
        public void InitializeFromEnumAndSave()
        {
            UomQtyENUM c = UomQtyENUM.Unknown;

            //this will create customer categories for the Enums


            var listOfEnums = Enum.GetNames(c.GetType()).ToList();

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


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

                switch (item.ToLower())
                {
                case "count":
                    uomQty.Multiplier = 1;
                    break;

                case "dz":
                    uomQty.Multiplier = 12;
                    break;

                case "ea":
                    uomQty.Multiplier = 1;
                    break;

                case "pair":
                    uomQty.Multiplier = 2;
                    break;

                case "single":
                    uomQty.Multiplier = 1;
                    break;
                }
                uomQty.MetaData.Comment = "Initialized automatically on " + DateTime.UtcNow;

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