Fix: ahora los remitos guardan bien
This commit is contained in:
@@ -30,11 +30,36 @@ namespace Modelo
|
||||
|
||||
public override void Add(Remito t)
|
||||
{
|
||||
t.Lotes = context.Lotes.Where(x => x.IdRemito == t.Id).ToList();
|
||||
if (t.Lotes == null) return;
|
||||
|
||||
|
||||
t.Proveedor = context.Proveedores.First(x => x.Cuit == t.Proveedor.Cuit);
|
||||
|
||||
var listaLotes = new List<Lote>();
|
||||
|
||||
|
||||
foreach (var lote in t.Lotes)
|
||||
{
|
||||
listaLotes.Add((Lote)lote.Clone());
|
||||
listaLotes.Last().Producto = lote.Producto;
|
||||
}
|
||||
|
||||
foreach (var lote in listaLotes)
|
||||
{
|
||||
lote.Producto = (lote.Producto.EsPerecedero) ?
|
||||
context.ProductoPercederos.FirstOrDefault(x => x.Id == lote.Producto.Id) :
|
||||
context.ProductoNoPercederos.FirstOrDefault(x => x.Id == lote.Producto.Id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
t.Lotes = listaLotes;
|
||||
|
||||
|
||||
context.Remitos.Add(t);
|
||||
}
|
||||
|
||||
|
||||
public override void Del(Remito t)
|
||||
{
|
||||
Remito rem = context.Remitos.First(x => x.Id == t.Id);
|
||||
|
||||
Reference in New Issue
Block a user