I want to move 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");
}