An aid to not doing something much more laborious than it can be soon of face. I have the following classes in my Model :
public Pessoa {
public int Id { get; set; }
public int TipoPessoaId { get; set; }
public string Nome { get; set; }
public ICollection<Contato> Contatos { get; set; }
public ICollection<Refencia> Referencias { get; set; }
//...
}
public Conjuge {
public int Id { get; set; }
public int PessoaId { get; set; }
public string Nome { get; set; }
public Pessoa Pessoa { get; set; }
//...
}
public Contato {
public int Id { get; set; }
public int PessoaId { get; set; }
public string Anotacao { get; set; }
public string Numero { get; set; }
public Pessoa Pessoa { get; set; }
//...
}
public Referencia {
public int Id { get; set; }
public int PessoaId { get; set; }
public string Nome { get; set; }
public string Anotacao { get; set; }
public Pessoa Pessoa { get; set; }
//...
}
And the question is this: I need to mount my view (single-page) as follows:
- Person Fields
- Spouse Fields
- Person can have N Contacts
- Form add Contact to Person
- Person can have N References
- Form add Reference for Person
But I do not know what the best or least problematic way to get the view. But my biggest problem is in controller .
Remembering that there are basic things to take into account: contact can only exist if there is a person with id for it, the same is given as reference, and these two cases will be a list that can be incremented ... and how in the view assign this list to model ?
In my action how would I do it? That is, I want to know how this view should be passed which I think will be complex for action . Should I pass a FORM or can I pass the Object?