falta que se actualize numProducto y los infomes

This commit is contained in:
2024-08-11 18:26:09 -03:00
parent cff13f1e47
commit 4262d66025
42 changed files with 724 additions and 471 deletions

View File

@@ -11,6 +11,7 @@ namespace Controladora
{
public class ControladoraLotes : Singleton<ControladoraLotes>
{
/*
public string Añadir(Lote t)
{
if (t == null) return "El Lote es nulo, falló la carga";
@@ -64,21 +65,39 @@ namespace Controladora
return $"Ocurrió un error inesperado: {ex.Message}";
}
}
*/
/*public ReadOnlyCollection<Lote> ListarPorFacturaId(int facturaId)
public string DisminuirStock(ReadOnlyCollection<DetalleFactura> detalleFactura)
{
try
var ret = false;
foreach (var detalle in detalleFactura)
{
var lotes = RepositorioLote.Instance.Listar();
var lotesPorFactura = lotes.Where(lote => lote.Id == facturaId).ToList();
return new ReadOnlyCollection<Lote>(lotesPorFactura);
if (detalle == null) return "El detalle es nulo";
if (detalle.Producto.Id < 0) return "Esta mal cargada la Id de producto";
var productos = RepositorioProductos.Instance.Listar();
if (productos.Any(x => x.Id != detalle.Producto.Id)) return "No hay Productos con esa id";
ret = RepositorioLote.Instance.DisminuirStock(detalle);
}
catch (Exception ex)
{
// Captura cualquier excepción no prevista
throw new InvalidOperationException($"Ocurrió un error inesperado: {ex.Message}");
}
}*/
return (ret) ?
"Se Descontaron los productos":
"Se fallo al diminuir el stock";
}
public int MostrarStockDeProducto(Producto producto)
{
if (producto == null) return -1;
if (producto.Id < 0) return -1;
var lotes = RepositorioLote.Instance.Listar();
if (lotes.Any(x => x.Producto.Id != producto.Id)) return -1; // basicamente no hay productos con esa id
var CantidadStock = lotes
.Where(x => x.Producto.Id == producto.Id)
.Sum(x=> x.Cantidad);
return CantidadStock;
}
public ReadOnlyCollection<Lote> Listar()
{