Skip to content

Instantly share code, notes, and snippets.

@lucasselliach
Created April 9, 2015 20:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasselliach/d29385373f4a056768a9 to your computer and use it in GitHub Desktop.
Save lucasselliach/d29385373f4a056768a9 to your computer and use it in GitHub Desktop.
All Servise Base
public interface IServiceBase<TEntity> where TEntity : class
{
void Add(TEntity obj);
TEntity GetById(int id);
IEnumerable<TEntity> GetAll();
void Update(TEntity obj);
void Remove(TEntity obj);
void Dispose();
}
public class ServiceBase<TEntity> : IDisposable, IServiceBase<TEntity> where TEntity : class
{
private readonly IRepositoryBase<TEntity> _repository;
public ServiceBase(IRepositoryBase<TEntity> repository)
{
_repository = repository;
}
public void Add(TEntity obj)
{
_repository.Add(obj);
}
public TEntity GetById(int id)
{
return _repository.GetById(id);
}
public IEnumerable<TEntity> GetAll()
{
return _repository.GetAll();
}
public void Update(TEntity obj)
{
_repository.Update(obj);
}
public void Remove(TEntity obj)
{
_repository.Remove(obj);
}
public void Dispose()
{
_repository.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment