Esempio n. 1
0
        public static SelectList ToSelectList <EnumType>(this EnumType enumObject)
            where EnumType : struct, IComparable, IFormattable, IConvertible
        {
            var values = from EnumType e in Enum.GetValues(typeof(EnumType))
                         select new { Id = e, Name = GlobalHelpers.t(e.ToString()) };

            return(new SelectList(values, "Id", "Name", enumObject));
        }
Esempio n. 2
0
        public static IEnumerable <SelectListItem> EnumToList <TEnum>(this TEnum enumObj, bool useIntegerValue) where TEnum : struct
        {
            Type type = typeof(TEnum);

            var values = from TEnum e in Enum.GetValues(typeof(TEnum))
                         select
                         new SelectListItem
            {
                Value =
                    (useIntegerValue)
                                         ? Enum.Format(type, Enum.Parse(type, e.ToString()), "d")
                                         : e.ToString(),
                Text     = GlobalHelpers.t(e.ToString()),
                Selected =
                    (useIntegerValue)
                                         ? (Convert.ToInt32(e) & Convert.ToInt32(enumObj)) == Convert.ToInt32(e)
                                         : enumObj.ToString().Contains(e.ToString())
            };


            return(values);
        }
        public override bool ValidateUser(string username, string password)
        {
            var userID = WebSecurity.GetUserId(username);

            return(GlobalHelpers.CheckUser(userID, username, password));
        }