cosas que faltaban
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user