me duelen los ojos
This commit is contained in:
@@ -6,11 +6,22 @@ namespace Controladora
|
||||
{
|
||||
public class ControladoraFacturas : Singleton<ControladoraFacturas>
|
||||
{
|
||||
private RepositorioFactura repositorioFacturas;
|
||||
public ControladoraFacturas()
|
||||
{
|
||||
repositorioFacturas = new(new Context());
|
||||
}
|
||||
|
||||
private bool ExistePorId(int id)
|
||||
{
|
||||
var fac = repositorioFacturas.ObtenerPorId(id);
|
||||
return (fac.Id == id);
|
||||
}
|
||||
public string Añadir(Factura t)
|
||||
{
|
||||
if (t == null) return "La Factura es nula, fallo la carga";
|
||||
|
||||
if (RepositorioFactura.Instance.ExistePorId(t.Id)) return $"La Factura con el ID {t.Id} ya existe";
|
||||
if (ExistePorId(t.Id)) return $"La Factura con el ID {t.Id} ya existe";
|
||||
if (t.Cliente == null || t.Cliente.Cuit == 0) return "Debe seleccionar un cliente antes de agregar la factura";
|
||||
|
||||
string checkstock = "";
|
||||
@@ -28,7 +39,8 @@ namespace Controladora
|
||||
|
||||
try
|
||||
{
|
||||
bool resultado = RepositorioFactura.Instance.Add(t);
|
||||
repositorioFacturas.Add(t);
|
||||
bool resultado = repositorioFacturas.Guardar();
|
||||
string resultadolote = ControladoraLotes.Instance.DisminuirStock(t.MostrarDetalles());
|
||||
|
||||
// Convierte ReadOnlyCollection a List
|
||||
@@ -58,9 +70,13 @@ namespace Controladora
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ReadOnlyCollection<Factura> Listar()
|
||||
{
|
||||
return RepositorioFactura.Instance.Listar();
|
||||
return repositorioFacturas.Listar()
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<DetalleFactura> ListarDetallesFactura(Factura factura)
|
||||
@@ -73,17 +89,12 @@ namespace Controladora
|
||||
|
||||
public ReadOnlyCollection<Producto> ListarProductos()
|
||||
{
|
||||
return RepositorioProductos.Instance.Listar()
|
||||
.Where(x => x.Habilitado == true)
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
return ControladoraProductos.Instance.Listar();
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<Cliente> ListarClientes()
|
||||
{
|
||||
return RepositorioClientes.Instance.Listar().Where(x => x.Habilitado == true)
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
return ControladoraClientes.Instance.Listar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user