public static String DisplayCategoryColor(this HtmlHelper htmlHelper, EnumTxnType category) { var className = ""; if (category == EnumTxnType.Revenue) { className = "text-success"; } else if (category == EnumTxnType.Expense) { className = "text-danger"; } return(className); }
public static string GetEnumDescription(this EnumTxnType source) { FieldInfo fi = source.GetType().GetField(source.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( typeof(DescriptionAttribute), false); if (attributes.Length > 0) { return(attributes[0].Description); } else { return(source.ToString()); } }