cosas que faltaban

This commit is contained in:
2024-08-11 18:23:17 -03:00
parent 08cb7d769f
commit c6ed194e04
77 changed files with 2333 additions and 25531 deletions

View File

@@ -7,22 +7,31 @@ namespace Modelo
{
override public bool Add(Factura t)
{
bool ret = false;
if (ExistePorId(t.Id))
{
throw new InvalidOperationException($"La Factura con el ID {t.Id} ya existe.");
}
if (t.Cliente == null || t.Cliente.Cuit == 0)
{
throw new InvalidOperationException("Debe seleccionar un cliente antes de agregar la factura.");
}
try
{
almacen.Add(t);
ret = true;
return true;
}
catch (Exception)
catch (Exception ex)
{
throw;
// Mejor manejo de excepciones, podrías registrar el error
throw new Exception("Error al agregar la factura.", ex);
}
return ret;
}
override public bool Mod(Factura t)
public bool ExistePorId(int id)
{
return almacen.Any(f => f.Id == id);
}
override public bool Mod(Factura t)
{
bool ret = false;