I am trying to return json result from mvc action. But when serialize enum property it return the numeric value of the enum. I want to string value of enum during json result. Following is the code sniped:
[HttpGet]
public ActionResult EventOrderDetail(string orderId, long eventId)
{
EventOrderDetailViewModel order = _service.GetOrderDetails(orderId, eventId);
return Json(order, JsonRequestBehavior.AllowGet);
}
Return Class have definition as
public class EventOrderDetailViewModel
{
public long OId { get; set; }
public string OrderId { get; set; }
public string BuyerName { get; set; }
public string TicketName { get; set; }
public string BuyerEmail { get; set; }
public string CustomerEmail { get; set; }
public long Quantity { get; set; }
public decimal Price { get; set; }
public decimal PricePaid { get; set; }
public decimal PriceNet { get; set; }
public decimal Fee { get; set; }
public decimal MerchantFee { get; set; }
public DateTime Date { get; set; }
public string DateStr { get; set; }
public PaymentStates PaymentState { get; set; }
public string Address { get; set; }
public string PromoCode { get; set; }
public string MailTickets { get; set; }
private List<Event_VariableDesc> _variableChages = new List<Event_VariableDesc>();
public List<Event_VariableDesc> VariableChages
{
get { return _variableChages; }
set { _variableChages = value; }
}
public string VariableIds { get; set; }
public string PhoneNumber { get; set; }
}
public enum PaymentStates { Total, Completed, Pending }
Output:
{ "PaymentStates" : 1,...}
I want Output:
{ "PaymentStates" : "Total",...}
How we can solved this?
Thanks in advance