Exemplo n.º 1
0
 public IEnumerable <TEntity> GetAll()
 {
     using (var context = new SSAAppContext())
     {
         var entity = context.Server.ToListAsync().Result;
         return(entity as IEnumerable <TEntity>);
     }
 }
Exemplo n.º 2
0
 public TEntity GetById(int id)
 {
     using (var context = new SSAAppContext())
     {
         var entity = context.Server.FirstAsync(x => x.IdServer == id).Result;
         return(entity as TEntity);
     }
 }
Exemplo n.º 3
0
 public TEntity Modify(TEntity entity)
 {
     using (var context = new SSAAppContext())
     {
         context.Entry(entity).State = EntityState.Modified;
         context.SaveChanges();
         return(entity);
     }
 }
Exemplo n.º 4
0
 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);
     }
 }