29 lines
671 B
C#
29 lines
671 B
C#
using System.Collections.ObjectModel;
|
|
using Entidades;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Modelo;
|
|
|
|
public abstract class RepositorioBase<T> where T : class, new()
|
|
{
|
|
protected AlquilaFacilContext Context { get; set; } = new AlquilaFacilContext();
|
|
|
|
public abstract ReadOnlyCollection<T> Listar();
|
|
|
|
public bool Guardar(){
|
|
bool ret = false;
|
|
try
|
|
{
|
|
Context.SaveChanges();
|
|
Context.Dispose();
|
|
Context = new AlquilaFacilContext();
|
|
ret = true;
|
|
} catch (DbUpdateException ex)
|
|
{
|
|
Console.Error.WriteLine(ex.Message);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
}
|