I have a model with enumerated properties as below:
namespace ProjectManager.Models
{
public class Contract
{
.....
public enum ContractStatus
{
[System.ComponentModel.Description("جديد")]
New,
[System.ComponentModel.Description("در انتظار پرداخت")]
WaitForPayment,
[System.ComponentModel.Description("پرداخت شده")]
Paid,
[System.ComponentModel.Description("خاتمه يافته")]
Finished
};
public ContractStatus Status { get; set; }
.....
}
}
Inside my razor views, I want to display enum descriptions for each item, e.g. جديد
instead of New
. I tried to follow instructions in this answer, but I don't know where to add extension method and how to call extension method inside my razor view file. I would be thankful if someone can complete my code:
@model IEnumerable<ProjectManager.Models.Contract>
....
<table class="table">
<tr>
.....
<th>@Html.DisplayNameFor(model => model.Status)</th>
.....
</tr>
@foreach (var item in Model) {
<tr>
......
<td>
@Html.DisplayFor(modelItem => item.Status) //<---what should i write here?
</td>
....
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })|
</td>
</tr>
}