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