me duelen los ojos
This commit is contained in:
@@ -37,6 +37,39 @@ namespace Modelo
|
||||
context.Lotes.Update(t);
|
||||
}
|
||||
|
||||
public bool DisminuirStock(DetalleFactura detalleFactura)
|
||||
{
|
||||
var detalle = context.DetalleFacturas.First(x => x.Id == detalleFactura.Id);
|
||||
bool ret = false; int cantidad = detalle.Cantidad;
|
||||
while (cantidad > 0)
|
||||
{
|
||||
var elementoAdisminuir = context.Lotes.Where(x => x.Habilitado == true)
|
||||
.First(x => x.Producto.Id == detalle.Producto.Id);
|
||||
|
||||
cantidad -= elementoAdisminuir.Cantidad;
|
||||
|
||||
if (cantidad > 0)
|
||||
{
|
||||
elementoAdisminuir.Cantidad = 0;
|
||||
elementoAdisminuir.Habilitado = false;
|
||||
}
|
||||
else if (cantidad == 0)
|
||||
{
|
||||
elementoAdisminuir.Cantidad = 0;
|
||||
elementoAdisminuir.Habilitado = false;
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elementoAdisminuir.Cantidad = -cantidad;
|
||||
ret = true;
|
||||
}
|
||||
context.Lotes.Update(elementoAdisminuir);
|
||||
|
||||
}
|
||||
context.DetalleFacturas.Update(detalle);
|
||||
return ret;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Modelo/RepositorioProductos.cs
Normal file
13
Modelo/RepositorioProductos.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Modelo
|
||||
{ // creo que lo voy a hacer como un desvio para que si cargas un producto percedero vaya para alla
|
||||
// y si es nopercedero vaya para otro lado. pero centralizado acá como una posibilidad.
|
||||
public class RepositorioProductos
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user