I have a form with the following input.
<div class="form-group">
<label class="control-label col-md-2" for="nome">Logradouro</label>
<div class="col-md-10"> @Html.EditorFor(model => model.endereco.Logradouro, new { htmlAttributes = new { @class = "form-control", required = "required" } }) @Html.ValidationMessageFor(model => model.endereco.Logradouro, "", new { @class = "text-danger" })
</div>
</div>
But when my action is triggered the value is not set in my model
@model Model.Empresa
My Action
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Empresa(Empresa empresa)
{
new EmpresaBO().Inserir(empresa);
new EnderecoBO().Inserir(empresa.endereco, empresa.Cnpj);
return RedirectToAction("Home", "Dashboard", new { area = "" });
}
My class
public class Empresa
{
private string razaoSocial;
private string contato;
private bool ativa;
private string naturezaJuri;
private string nomeFan;
private string cnpj;
public Departamento departamentos;
public Endereco endereco;
public Administrador administrador;
}
Only values that are primitive within my class are returned to my action, how can I resolve this?