0
I am creating an Asp.net application with customer registration. I am creating the Create page, which has the client’s own registration fields. However, the customer can have multiple phones. Soon, my Viewmodel has the following structure:
public class ClienteViewModel
{
public ClienteViewModel()
{
Id = Guid.NewGuid();
}
[Key]
public Guid Id { get; set; }
[Required(ErrorMessage = "O nome é requerido")]
[Display(Name = "Nome")]
[StringLength(80, MinimumLength = 5, ErrorMessage = "{0} deve ter no mínimo 5 e no máximo 80 caracteres.")]
public string Nome { get; set; }
[Required(ErrorMessage = "A Data de Nascimento é requerida")]
[Display(Name = "Data de Nascimento")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime DataNascimento { get; set; }
}
However, how can I send this phone list in Controller in a structure like this? I could use Ajax with partialView, but then I would have to have the ID (the client registered first). I would like to know the best way to do something similar to the screen below:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(ClienteViewModel clienteViewModel)
is a
array
ofstring
guypublic string[] Telefones {get;set;}
– novic
But how to pass this, since they are in different fields? How to organize to send by post (without ajax)?
– ComplexityAlg