Hello, I'd like some help. I have this method to save the data into 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 when you save it saves only 1 item, and is the last item, I would like to know how I can save everything at once. Thank you !!