2
I am creating an application where the user will be able to select a variety of products through checkbox
. But when I click on "Buy" the list is empty. Someone can give me a help with this?
That code is from View:
<tbody>
@foreach (var servico in Model.Servicos)
{
<tr>
<td>
@servico.Descricao_Servico
</td>
<td>
@servico.Valor_Servico
</td>
<td>
<label class="checkbox inline">
<input type="checkbox" id="@servico.Id" />
</label>
</td>
</tr>
}
</tbody>
This next one is the controller
public ActionResult Cadastrar()
{
var modelo = ModeloCadastrar();
return View(modelo);
}
private CadastrarAgendamentoViewModel ModeloCadastrar()
{
var modelo = new CadastrarAgendamentoViewModel();
var ddlListaDeFuncionarios = _contexto.Funcionarios.ToList();
var ddlListaDeServicos = _contexto.Servicos.ToList();
var ddlProdutos = _contexto.Produtos.ToList();
modelo.ListaDeFuncionarios = (from funcionarios in ddlListaDeFuncionarios
select new SelectListItem
{
Text = funcionarios.Nome_Usuario,
Value = funcionarios.Id.ToString(),
}).ToList();
modelo.ListaDeProdutos = (from produtos in ddlProdutos
select new SelectListItem
{
Text = produtos.Descricao_Produto,
Value = produtos.Id.ToString(),
}).ToList();
modelo.Servicos = ddlListaDeServicos;
modelo.Data_Agendamento = System.DateTime.Now;
modelo.Hora_Agendamento = "08:00";
return modelo;
}
Use the edit link in your question to add other information. The Post Answer button should only be used to complete answers to the question.
– Fernando Leal