public int Delete(Pemain obj) { int result = 0; using (IDbContext context = new DbContext()) { _repository = new PemainRepository(context); result = _repository.Delete(obj); } return(result); }
public Pemain GetByID(int id) { Pemain obj = null; using (IDbContext context = new DbContext()) { _repository = new PemainRepository(context); obj = _repository.GetByID(id); } return(obj); }
public IList <Pemain> GetAll() { var lstObj = new List <Pemain>(); using (IDbContext context = new DbContext()) { _repository = new PemainRepository(context); lstObj = _repository.GetAll().ToList(); } return(lstObj); }
private bool NamaIsUnique(string nama, int id = 0) { Pemain obj = null; using (IDbContext context = new DbContext()) { _repository = new PemainRepository(context); obj = _repository.GetByNama(nama); } if (obj == null || obj.id == id) { return(true); // unique } return(false); }
public int Update(Pemain obj) { if (!NamaIsUnique(obj.nama, obj.id)) { return(-1); } int result = 0; using (IDbContext context = new DbContext()) { _repository = new PemainRepository(context); result = _repository.Update(obj); } return(result); }