I am trying to get the description from an array of enums bascically this is the current structure that I have.
public enum IllinoisNonDisclosureConvictionFormOptions
{
[Description("625 ILCS 5/11-501 - Driving Under the Influence")]
answerConviction0 = 0,
[Description("625 ILCS 5/11-503 - Reckless Driving")]
answerConviction1 = 1,
[Description("a violation of Article 11 of the Criminal Code of 1961, not including prostitution under 720 ILCS 5 / 11 - 14")]
answerConviction2 = 2,
[Description("720 ILCS 5/26-5 - Dog Fighting")]
answerConviction3 = 3,
[Description("720 ILCS 5/12-1 - Assault")]
answerConviction4 = 4,
}
So basically a user will select the crime they committed and then that text will be compared in a if statement to the description of the enums. What I currently have is this:
if (request.Question4 != null)
{
var answersForQuestion4 = Enum.GetValues(typeof(IllinoisNonDisclosureConvictionFormOptions)).Cast<IllinoisNonDisclosureConvictionFormOptions>().ToList();
foreach (Enum answer in answersForQuestion4)
{
//I need to compare the description to the selected text
string description = (enum description value)
if (request.Question4 == description)
{return description}
}
}
I may have to switch from enums to ControllersConstants since I dont really need to save their answers in the database. Please let me know if you have any insights regarding this matter.