1
I want to go from View
<table style="width:100%">
<tr>
<th>Serviço</th>
<th>Data</th>
<th>Feito</th>
</tr>
@{
foreach (var item in ViewBag.servico)
{
<tr>
<td>@item.Servico</td>
<td>@item.Data</td>
<td>@item.Feito</td>
<td>Editar</td>
<td>
<form action="/Tarefas/Remover" method="post">
@{
var tarefa = item;
}
<input type="submit" value="Excluir" />
</form>
</td>
</tr>
}
}
For the controller:
[HttpPost]
public IActionResult Remover(Tarefa tarefa)
{
using (var item = new AgendaDBContext())
{
item.Servicos.Remove(tarefa);
item.SaveChanges();
}
return View("Lista");
}
Already tried passing only the controller in Action?
<form action="/Tarefas" method="post">
– Marconi
<form action="/Tasks/Remove" method="post"> I’m going through post, I just don’t know how to pass the object
– Robson Junior
Your fields need to be inside the form and attribute
name
fields need to be the same properties names that refer to their modelTarefa
.– Pedro Paulo
Include the structure of the entity
Tarefa
in your question– Leandro Angelo