Exemple #1
0
 public int Update(T entity)
 {
     using (GovernmentDbContext entityContext = new GovernmentDbContext())
     {
         entityContext.Entry <T>(entity).State = EntityState.Modified;
         return(entityContext.SaveChanges());
     }
 }
Exemple #2
0
 public int Remove(T entity)
 {
     using (GovernmentDbContext entityContext = new GovernmentDbContext())
     {
         entityContext.Entry <T>(entity).State = EntityState.Deleted;
         return(entityContext.SaveChanges());
     }
 }
Exemple #3
0
        public int Add(T entity)
        {
            int result = 0;

            using (GovernmentDbContext entityContext = new GovernmentDbContext())
            {
                var obj = AddEntity(entityContext, entity);
                result = entityContext.SaveChanges();
            }
            return(result);
        }
Exemple #4
0
 public T UpdatewithObj(T entity)
 {
     using (GovernmentDbContext entityContext = new GovernmentDbContext())
     {
         entityContext.Entry <T>(entity).State = EntityState.Modified;
         if (entityContext.SaveChanges() > 0)
         {
             return(entity);
         }
         return(null);
     }
 }
Exemple #5
0
 public T AddWithGetObj(T entity)
 {
     using (GovernmentDbContext entityContext = new GovernmentDbContext())
     {
         var obj = AddEntity(entityContext, entity);
         if (entityContext.SaveChanges() > 0)
         {
             return(obj);
         }
     }
     return(null);
 }