Exemplo n.º 1
0
 public static List <User> GetAllUsers(Guid queryGuid)
 {
     using (var context = new RandomizerDBContext())
     {
         return(context.Users.Where(u => u.Queries.All(r => r.Guid != queryGuid)).ToList());
     }
 }
Exemplo n.º 2
0
 public static User GetUserByGuid(Guid guid)
 {
     using (var context = new RandomizerDBContext())
     {
         return(context.Users.Include(u => u.Queries).FirstOrDefault(u => u.Guid == guid));
     }
 }
Exemplo n.º 3
0
 public static User GetUserByLogin(string login)
 {
     using (var context = new RandomizerDBContext())
     {
         return(context.Users.Include(u => u.Queries).FirstOrDefault(u => u.Login == login));
     }
 }
Exemplo n.º 4
0
 public static bool UserExists(string login)
 {
     using (var context = new RandomizerDBContext())
     {
         return(context.Users.Any(u => u.Login == login));
     }
 }
Exemplo n.º 5
0
 public static void SaveQuery(Query query)
 {
     using (var context = new RandomizerDBContext())
     {
         context.Entry(query).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public static void AddUser(User user)
 {
     using (var context = new RandomizerDBContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void AddQuery(Query query)
 {
     using (var context = new RandomizerDBContext())
     {
         query.DeleteDatabaseValues();
         context.Queries.Add(query);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public static void DeleteQuery(Query selectedQuery)
 {
     using (var context = new RandomizerDBContext())
     {
         selectedQuery.DeleteDatabaseValues();
         context.Queries.Attach(selectedQuery);
         context.Queries.Remove(selectedQuery);
         context.SaveChanges();
     }
 }