Exemplo n.º 1
0
 public LoginPermission GetById(int id)
 {
     using (var context = new FuelManagementEntities())
     {
         return(context.LoginPermissions.FirstOrDefault(x => x.Id == id));
     }
 }
Exemplo n.º 2
0
 public LoginPermission GetByUserID(int userId)
 {
     using (var context = new FuelManagementEntities())
     {
         return(context.LoginPermissions.FirstOrDefault(x => x.UserID == userId));
     }
 }
Exemplo 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));
     }
 }
Exemplo 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));
     }
 }
Exemplo n.º 7
0
 public virtual T Insert(T entity)
 {
     using (var context = new FuelManagementEntities())
     {
         context.Set(GetEntityType()).Add(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Exemplo 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();
     }
 }
Exemplo 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);
     }
 }
Exemplo 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());
         }
     }
 }
Exemplo 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());
         }
     }
 }