This repository has been archived on 2024-08-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Final_OOP/Modelo/RepositorioPresupuesto.cs

75 lines
1.7 KiB
C#

using System.Collections.ObjectModel;
using Entidades;
namespace Modelo
{
public sealed class RepositorioPresupuesto : RepositorioBase<Presupuesto, RepositorioPresupuesto>
{
override public bool Add(Presupuesto t)
{
bool ret = false;
try
{
almacen.Add(t);
ret = true;
}
catch (Exception)
{
throw;
}
return ret;
}
override public bool Mod(Presupuesto t)
{
bool ret = false;
try
{
var presupuestoAModificar = almacen.FindIndex(x => x.Id == t.Id);
if (presupuestoAModificar > -1)
{
almacen[presupuestoAModificar] = t;
ret = true;
}
}
catch (Exception)
{
throw;
}
return ret;
}
override public bool Del(Presupuesto t)
{
bool ret = false;
try
{
var presupuestoAEliminar = almacen.Find(x => x.Id == t.Id);
if (presupuestoAEliminar != null)
{
almacen.Remove(presupuestoAEliminar);
ret = true;
}
}
catch (Exception)
{
throw;
}
return ret;
}
public ReadOnlyCollection<DetallePresupuesto> MostrarDetalles(Presupuesto presupuesto)
{
return presupuesto.MostrarDetalles();
}
}
}