Fix: ahora los remitos guardan bien
This commit is contained in:
@@ -17,16 +17,7 @@ namespace Controladora
|
|||||||
{
|
{
|
||||||
repositorioLotes = new(new Context());
|
repositorioLotes = new(new Context());
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AltaStock(Remito t)
|
|
||||||
{
|
|
||||||
if (t == null) return "Esta Mal Cargado";
|
|
||||||
|
|
||||||
repositorioLotes.Add(t);
|
|
||||||
return repositorioLotes.Guardar() ?
|
|
||||||
"Se Cargo Correctamente" :
|
|
||||||
"Fallo la Carga";
|
|
||||||
}
|
|
||||||
public string DisminuirStock(ReadOnlyCollection<DetalleFactura> detalleFactura)
|
public string DisminuirStock(ReadOnlyCollection<DetalleFactura> detalleFactura)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ namespace Controladora
|
|||||||
orden.Entregado = true;
|
orden.Entregado = true;
|
||||||
var retMarcarOrdenEntregada = ControladoraOrdenDeCompras.Instance.Modificar(orden);
|
var retMarcarOrdenEntregada = ControladoraOrdenDeCompras.Instance.Modificar(orden);
|
||||||
|
|
||||||
|
|
||||||
repositorioRemito.Add(t);
|
repositorioRemito.Add(t);
|
||||||
ControladoraLotes.Instance.AltaStock(t);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (repositorioRemito.Guardar()) ?
|
return (repositorioRemito.Guardar()) ?
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace Entidades
|
namespace Entidades
|
||||||
{
|
{
|
||||||
public class Lote: Detalle<Producto>
|
public class Lote : Detalle<Producto>, ICloneable
|
||||||
{
|
{
|
||||||
public int IdRemito { get; set; }
|
public int IdRemito { get; set; }
|
||||||
public DateTime Fecha { get; set; }
|
public DateTime Fecha { get; set; }
|
||||||
@@ -17,6 +17,26 @@ namespace Entidades
|
|||||||
return Producto.Nombre;
|
return Producto.Nombre;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Lote() { }
|
||||||
|
|
||||||
|
/// ICLONEABLE IMPLEMENTATION
|
||||||
|
/// <summary>
|
||||||
|
/// ICLONEABLE IMPLEMENTATION
|
||||||
|
private Lote(Lote lote)
|
||||||
|
{
|
||||||
|
Id = lote.Id;
|
||||||
|
Cantidad = lote.Cantidad;
|
||||||
|
|
||||||
|
IdRemito = lote.IdRemito;
|
||||||
|
Fecha = lote.Fecha;
|
||||||
|
Habilitado = lote.Habilitado;
|
||||||
|
|
||||||
|
}
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new Lote(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,36 @@ namespace Modelo
|
|||||||
|
|
||||||
public override void Add(Remito t)
|
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);
|
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);
|
context.Remitos.Add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Del(Remito t)
|
public override void Del(Remito t)
|
||||||
{
|
{
|
||||||
Remito rem = context.Remitos.First(x => x.Id == t.Id);
|
Remito rem = context.Remitos.First(x => x.Id == t.Id);
|
||||||
|
|||||||
Reference in New Issue
Block a user