I'm looking to create a page using best practices in ASP.NET MVC.
I wondered what would be the best practice for me to model my page using modelbinders to "bind" my object automatically. In this case, my doubt was in the relationships between classes, see for example my scenario:
public class Pessoa
{
[Key]
public int ID { get; set; }
public string Nome { get; set; }
public Perfil Perfil { get; set; }
}
public class Perfil
{
[Key]
public int ID { get; set; }
public string Nome { get; set; }
}
In my view, it would look something like this:
@model Pessoa
<div class="col-md-3">
@Html.TextBoxFor(c => c.Pessoa.naturezaOcorrencia, Model.GetStatus())
</div>
<div class="col-md-3">
@Html.DropDownListFor(c => c.Perfil, ???????)
</div>
So, as I would finish filling the DropDownList. It does not accept a direct Entity list for example: Perfil.All().ToList();