How do I get the ID from the first table to record the second?
Recalling that the id and generated automatic.
[HttpPost]
public ActionResult Create(Chamados chamados, InteracoesChamados interacoesChamados)
{
if (ModelState.IsValid)
{
db.Chamados.Add(chamados);
//interacoesChamados.ChamadoId = chamados.ChamadoId;
db.InteracoesChamados.Add(interacoesChamados);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(chamados);
}
The comment and exactly what I want to do.
I need get the code from the first table and save the second record.
What is the best way?
From looking at the code I assume that IteracoesChamados is a child of Chamados. If so, then set
The ID will be assigned automatically. Hope this helps.