me duelen los ojos
This commit is contained in:
@@ -11,6 +11,12 @@ namespace Controladora
|
||||
{
|
||||
public class ControladoraLotes : Singleton<ControladoraLotes>
|
||||
{
|
||||
private RepositorioLote repositorioLotes;
|
||||
public ControladoraLotes()
|
||||
{
|
||||
repositorioLotes = new(new Context());
|
||||
}
|
||||
|
||||
public string DisminuirStock(ReadOnlyCollection<DetalleFactura> detalleFactura)
|
||||
{
|
||||
var ret = false;
|
||||
@@ -18,12 +24,12 @@ namespace Controladora
|
||||
{
|
||||
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();
|
||||
var productos = ControladoraProductos.Instance.Listar();
|
||||
if (!productos.Any(x => x.Id == detalle.Producto.Id)) return "No hay Productos con esa id";
|
||||
ret = RepositorioLote.Instance.DisminuirStock(detalle);
|
||||
ret = repositorioLotes.DisminuirStock(detalle);
|
||||
|
||||
}
|
||||
|
||||
repositorioLotes.Guardar();
|
||||
return (ret) ?
|
||||
"Se Descontaron los productos":
|
||||
"Se fallo al diminuir el stock";
|
||||
@@ -34,7 +40,7 @@ namespace Controladora
|
||||
{
|
||||
if (producto == null) return 0;
|
||||
if (producto.Id < 0) return 0;
|
||||
var lotes = RepositorioLote.Instance.Listar();
|
||||
var lotes = repositorioLotes.Listar();
|
||||
if (!lotes.Any(x => x.Producto.Id == producto.Id)) return 0; // basicamente no hay productos con esa id
|
||||
|
||||
var CantidadStock = lotes
|
||||
@@ -45,16 +51,8 @@ namespace Controladora
|
||||
|
||||
public ReadOnlyCollection<Lote> Listar()
|
||||
{
|
||||
try
|
||||
{
|
||||
return RepositorioLote.Instance.Listar().Where(x=> x.Habilitado == true)
|
||||
return repositorioLotes.Listar().Where(x=> x.Habilitado == true)
|
||||
.ToList().AsReadOnly();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Captura cualquier excepción no prevista
|
||||
throw new InvalidOperationException($"Ocurrió un error inesperado: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user