0
I’m having a problem returning the Displayname of an Enum
I have the following Enum
public enum TipoPessoa
    {
        [Description("Pessoa Fisica")]
        [Display(Name = "Pessoa Fisica")]
        [JsonProperty("Pessoa Fisica")]
        Fisica = 0,
        [Display(Name = "Pessoa Juridica")]
        [Description("Pessoa Juridica")]
        [JsonProperty("Pessoa Juridica")]
        Juridica = 1
    }
and the following view model
public class EmpresaViewerViewModel
{
    public int Id { get; set; }
    [Display(Name = "Razão Social")]
    public string RazaoSocial { get; set; }
    [Display(Name = "Nome Fantasia")]
    public string NomeFantasia { get; set; }
    public int CNPJ { get; set; }
    [Display(Name = "Inscrição Estadual")]
    public int InscricaoEstadual { get; set; }
    [Display(Name = "Tipo de Pessoa")]
    public TipoPessoa TipoPessoa { get; set; }
    [Display(Name = "Código do Regime Tributário")]
    public CRT CRT { get; set; }
    public string Logradouro { get; set; }
    public string Complemento { get; set; }
    [DataType(DataType.PostalCode)]
    public string CEP { get; set; }
    public string Numero { get; set; }
    public string Bairro { get; set; }
    public string Cidade { get; set; }
    public string Estado { get; set; }
    [DataType(DataType.EmailAddress)]
    public string Email { get; set; }
    [DataType(DataType.PhoneNumber)]
    public string Telefone { get; set; }
    [DataType(DataType.PhoneNumber)]
    public string TelefoneCelular { get; set; }
}
and the following method in the controller
public JsonResult GetAll(string searchPhrase, int current = 1, int rowCount = 10)
    {
        // Ordenacao
        string columnKey = Request.Form.AllKeys.Where(k => k.StartsWith("sort")).First();
        string order = Request[columnKey];
        string field = columnKey.Replace("sort[", String.Empty).Replace("]", String.Empty);
        string fieldOrdened = String.Format("{0} {1}", field, order);
        List<PessoaEmpresa> pessoaEmpresa = repositoryEmpresa.Select();
        List<PessoaEmpresa> empresaPaginada = pessoaEmpresa.OrderBy(fieldOrdened).Skip((current - 1) * rowCount).Take(rowCount).ToList();
        List<EmpresaViewerViewModel> viewModel = AutoMapperManager.Instance.Mapper.Map<List<PessoaEmpresa>, List<EmpresaViewerViewModel>>(empresaPaginada);
        return  Json(new
        {
            rows = viewModel,
            current = current,
            rowCount = rowCount,
            total = pessoaEmpresa.Count()
        }, JsonRequestBehavior.AllowGet);
    }
But json returned the company type and crt comes as 0 or 1 and not the attribute name
tried that way didn’t work
– Jefferson Mello Olynyki