Esempio n. 1
0
 public LoginPermission GetById(int id)
 {
     using (var context = new FuelManagementEntities())
     {
         return(context.LoginPermissions.FirstOrDefault(x => x.Id == id));
     }
 }
Esempio n. 2
0
 public LoginPermission GetByUserID(int userId)
 {
     using (var context = new FuelManagementEntities())
     {
         return(context.LoginPermissions.FirstOrDefault(x => x.UserID == userId));
     }
 }
Esempio n. 3
0
 public virtual T GetByKey(object key)
 {
     using (var context = new FuelManagementEntities())
     {
         return((T)context.Set(GetEntityType()).Find(key));
     }
 }
 public PartnerServiceIntegration GetByClientID(int clientId, int AdminID)
 {
     using (var context = new FuelManagementEntities())
     {
         return(context.PartnerServiceIntegrations.FirstOrDefault(x => x.ClientID == clientId && x.AdminClientID == AdminID));
     }
 }
 public PartnerServiceIntegration GetByAccountID(Guid accountId)
 {
     using (var context = new FuelManagementEntities())
     {
         return(context.PartnerServiceIntegrations.FirstOrDefault(x => x.AccountNumber == accountId));
     }
 }
Esempio n. 6
0
 public virtual T GetByKeySerializable(object key)
 {
     using (var context = new FuelManagementEntities())
     {
         context.Configuration.LazyLoadingEnabled = false;
         return((T)context.Set(GetEntityType()).Find(key));
     }
 }
Esempio n. 7
0
 public virtual T Insert(T entity)
 {
     using (var context = new FuelManagementEntities())
     {
         context.Set(GetEntityType()).Add(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Esempio n. 8
0
 protected virtual void DeleteByKey(object key)
 {
     using (var context = new FuelManagementEntities())
     {
         T entityToUpdate = (T)context.Set(GetEntityType()).Find(key);
         if (entityToUpdate == null)
         {
             return;
         }
         context.Entry(entityToUpdate).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Esempio n. 9
0
 protected virtual T UpdateByKey(T entity, object key)
 {
     using (var context = new FuelManagementEntities())
     {
         if (key == null || ((int)key) == 0)
         {
             return(Insert(entity));
         }
         context.Set(GetEntityType()).Attach(entity);
         context.Entry(entity).State = EntityState.Modified;
         context.SaveChanges();
         return(entity);
     }
 }
Esempio n. 10
0
 public virtual List <T> GetList(System.Linq.Expressions.Expression <System.Func <T, bool> > predicate, string include = "")
 {
     using (var context = new FuelManagementEntities())
     {
         if (string.IsNullOrEmpty(include))
         {
             return(context.Set(GetEntityType()).AsQueryable().Cast <T>().Where(predicate).ToList());
         }
         else
         {
             return(context.Set(GetEntityType()).AsQueryable().Include(include).Cast <T>().Where(predicate).ToList());
         }
     }
 }
Esempio n. 11
0
 public virtual List <T> GetListSerializable(System.Linq.Expressions.Expression <Func <T, bool> > predicate, string include = "")
 {
     using (var context = new FuelManagementEntities())
     {
         context.Configuration.LazyLoadingEnabled = false;
         if (string.IsNullOrEmpty(include))
         {
             return(context.Set(GetEntityType()).AsQueryable().Cast <T>().Where(predicate).ToList());
         }
         else
         {
             return(context.Set(GetEntityType()).AsQueryable().Include(include).Cast <T>().Where(predicate).ToList());
         }
     }
 }