using Brizco.Common.Models.Entity;

namespace Brizco.Common.Extensions
{
    public static class ClassDisplayExtensions
    {
        public static string GetDisplayAttributeName<T>()
        {
            var attrs =
                Attribute.GetCustomAttributes(typeof(T));

            foreach (var attr in attrs)
            {
                var displayAttribute = attr as ClassDisplay;
                if (displayAttribute == null)
                    continue;
                return displayAttribute.GetName() ?? string.Empty;
            }

            return string.Empty;
        }

        public static string GetDisplayAttributeDescription<T>()
        {
            var attrs =
                Attribute.GetCustomAttributes(typeof(T));

            foreach (var attr in attrs)
            {
                var displayAttribute = attr as ClassDisplay;
                if (displayAttribute == null)
                    continue;
                return displayAttribute.GetDescription() ?? string.Empty;
            }

            return string.Empty;
        }
    }
}