I have the following classes:
class Disciplina
:
public class Disciplina
{
public int Id { get; set; }
public string Nome { get; set; }
}
interface IGenericaDAO
:
public interface IGenericaDAO<T>
{
bool Add(T e);
bool Update(T e);
bool Delete(T e);
List<T> GetAll();
T Get(int id);
}
interface IDisciplinaDAO
:
public interface IDisciplinaDAO : IGenericaDAO<Disciplina>
{
}
class GenericaDAO
:
public class GenericaDAO<T> : IGenericaDAO<T> where T : class
{
internal ApplicationDbContext Context { get; set; }
protected DbSet<T> DbSet { get; set; }
public GenericaDAO()
{
Context = new ApplicationDbContext();
DbSet = Context.Set<T>();
}
public bool Add(T e)
{
try
{
Context.Entry(e).State = EntityState.Added;
Context.SaveChanges();
return true;
}
catch (Exception ex)
{
throw ex;
}
}
public bool Update(T e)
{
try
{
Context.Entry(e).State = EntityState.Modified;
Context.SaveChanges();
return true;
}
catch (Exception ex)
{
throw ex;
}
}
public bool Delete(T e)
{
try
{
Context.Entry(e).State = EntityState.Deleted;
Context.SaveChanges();
return true;
}
catch (Exception ex)
{
throw ex;
}
}
public List<T> GetAll()
{
return DbSet.ToList();
}
public T Get(int id)
{
return DbSet.Find(id);
}
}
class DisciplinaDAO
:
public class DisciplinaDAO : GenericaDAO<Disciplina>, IDisciplinaDAO
{
}
interface IGenericaBLO
:
public interface IGenericaBLO<T>
{
bool Add(T e);
bool Update(T e);
bool Delete(T e);
List<T> GetAll();
T Get(int id);
}
public interface IGenericaBLO<T>
{
bool Add(T e);
bool Update(T e);
bool Delete(T e);
List<T> GetAll();
T Get(int id);
}
interface IDisciplinaBLO
:
public interface IDisciplinaBLO : IGenericaBLO<Disciplina>
{
}
class GenericaBLO
:
public class GenericaBLO<T> : IGenericaBLO<T> where T : class
{
private IGenericaDAO<T> dao;
public GenericaBLO(IGenericaDAO<T> _dao)
{
dao = _dao;
}
public bool Add(T e)
{
bool resultado = dao.Add(e);
return resultado;
}
public bool Update(T e)
{
bool resultado = dao.Update(e);
return resultado;
}
public bool Delete(T e)
{
bool resultado = dao.Delete(e);
return resultado;
}
public List<T> GetAll()
{
return dao.GetAll();
}
public T Get(int id)
{
return dao.Get(id);
}
}
class DisciplinaBLO
:
public class DisciplinaBLO : GenericaBLO<Disciplina>, IDisciplinaBLO
{}
I'm getting the following compile error in class DisciplinaBLO
:
Error 1 'Core.BLL.Base.GenericaBLO' does not contain a constructor that takes 0 arguments DisciplinaBLO.cs 12 18 Core