...I could use a controller to do the manipulations on the tables ?
Actually the controller does not manipulate tables.
Commenting roughly, the controller receives requests from the GET/POST user, maps to Action and returns a View. You have no responsibility to manipulate tables, That would be your Model’s responsibility.
So you can for example:
1- Create a class called Alunoviewmodel, which will be a kind of container of all the information required to register the student (for example: name, telephone, address, etc.). This class may even have a method to save the student.
public class AlunoViewModel
{
[Required]
public string Nome { get; set; }
[DisplayName("Endereço")]
public string Endereco { get; set; }
[DisplayName("Telefone")]
public string NumeroTelefone { get; set; }
public ICollection<Telefone> Telefones {get;set;}
// Demais propriedades
// Método para salvar um aluno
public static void Salvar(AlunoViewModel alunoViewModel)
{
//Seu código para salvar uma aluno
}
}
2- Create a controller and insert Actions (one to display the registration screen "GET", another to receive the data informed "POST")
public class AlunoController: Controller
{
public ActionResult Criar()
{
return View(new AlunoViewModel());
}
[HttpPost]
public ActionResult Criar(AlunoViewModel alunoViewModel)
{
//Agora usando as informações de alunoViewModel você chama o seu Model para criar os objetos (aluno, telefone, etc) e salvar no banco.
AlunoViewModel.Salvar(alunoViewModel);
}
}
3-Create Alunoviewmodel-like View to display in the register.
@model Models.AlunoViewModel
@{
ViewBag.Title = "Cadastro de Aluno";
}
@*
Aqui vai o código em razor para exibir as informações do cadastro
*@
Yes, it is feasible to register the student’s phone information, parents, etc whether or not using AJAX.
In the case of student phone registration, you may have a property Numerophone (textbox type control for example) and a button for the user to add the phone to the list (Listbox type control for example). As soon as the user enters the number, click on the button, you add the phone entered in the Listbox (related to Phones property). In the post of the registration screen you will receive this list of phones and associates to the student to save.
Related: http://answall.com/questions/39055/partial-n%C3%A3o-%C3%A9-rendered/39056#39056
– Leonel Sanches da Silva
You want me to put that one in there too @Gypsy ?
– Érik Thiago
No need. The link is already there on the right.
– Leonel Sanches da Silva