Created
April 9, 2015 20:20
-
-
Save lucasselliach/d29385373f4a056768a9 to your computer and use it in GitHub Desktop.
All Servise Base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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