asdas
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo
|
||||
{
|
||||
@@ -12,7 +13,12 @@ namespace Modelo
|
||||
|
||||
public override List<OrdenDeCompra> Listar()
|
||||
{
|
||||
return context.OrdenDeCompras.ToList();
|
||||
return context.OrdenDeCompras
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Proveedor)
|
||||
.Include(x => x.detalles)
|
||||
.ThenInclude(x => x.Producto)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrdenDeCompra ObtenerPorId(int Tid)
|
||||
@@ -23,6 +29,14 @@ namespace Modelo
|
||||
|
||||
public override void Add(OrdenDeCompra t)
|
||||
{
|
||||
t.Proveedor = context.Proveedores.First(x => x.Cuit == t.Proveedor.Cuit);
|
||||
|
||||
foreach (var detalle in t.detalles)
|
||||
{
|
||||
detalle.Producto = (detalle.Producto.EsPerecedero) ?
|
||||
context.ProductoPercederos.First(x => x.Id == detalle.Producto.Id) :
|
||||
context.ProductoNoPercederos.First(x => x.Id == detalle.Producto.Id);
|
||||
}
|
||||
context.OrdenDeCompras.Add(t);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user