public IEnumerable <TEntity> GetAll() { using (var context = new SSAAppContext()) { var entity = context.Server.ToListAsync().Result; return(entity as IEnumerable <TEntity>); } }
public TEntity GetById(int id) { using (var context = new SSAAppContext()) { var entity = context.Server.FirstAsync(x => x.IdServer == id).Result; return(entity as TEntity); } }
public TEntity Modify(TEntity entity) { using (var context = new SSAAppContext()) { context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(entity); } }
public TEntity Delete(int id) { using (var context = new SSAAppContext()) { var entity = context.Server.FirstOrDefaultAsync(x => x.IdServer == id).Result; if (entity != null) { context.Entry(entity).State = EntityState.Deleted; context.SaveChanges(); } return(entity as TEntity); } }