4
Hello, I would like a help. I have this method to save the data in two tables.
public void SalvarLocacao(Carrinho carrinho, Locacao locacao)
{
Item items = new Item();
foreach (var item in carrinho.ItensCarrinho)
{
items.LocacaoId = locacao.LocacaoId;
items.CacambaId = item.CacambaId;
items.Quantidade = item.Quantidade;
Db.Items.Add(items);
}
Db.Locacaos.Add(locacao);
Db.SaveChanges();
}
But at the time I save it saves only 1 item, and it is the last item, I would like to know how I do to save everything at once. Thank you !!
You’re saying if there are 3 items you’re saving 2 and the third one isn’t?
– Leonardo Nascimento Cintra