using System.ComponentModel.DataAnnotations;
using System.Reflection;
using CafeCritic.Enums;

namespace CafeCritic.Services;

public static class ExtensionsEnum
{
    public static string GetDisplayName(this Rating rating)
    {
        var displayAttribute = rating.GetType()
            .GetMember(rating.ToString())[0]
            .GetCustomAttributes(typeof(DisplayAttribute), false)[0] as DisplayAttribute;

        return displayAttribute.Name;
    }
}