Example #1
0
 public static List <User> GetAllUsers(Guid noteGuid)
 {
     using (var context = new NoteDBContext())
     {
         return(context.Users.Where(u => u.Notes.All(r => r.Guid != noteGuid)).ToList());
     }
 }
Example #2
0
 public static User GetUserByGuid(Guid guid)
 {
     using (var context = new NoteDBContext())
     {
         return(context.Users.Include(u => u.Notes).FirstOrDefault(u => u.Guid == guid));
     }
 }
Example #3
0
 public static User GetUserByLogin(string login)
 {
     using (var context = new NoteDBContext())
     {
         return(context.Users.Include(u => u.Notes).FirstOrDefault(u => u.Login == login));
     }
 }
Example #4
0
 public static bool UserExists(string login)
 {
     using (var context = new NoteDBContext())
     {
         return(context.Users.Any(u => u.Login == login));
     }
 }
Example #5
0
 public static void SaveNote(Note note)
 {
     using (var context = new NoteDBContext())
     {
         context.Entry(note).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #6
0
 public static void AddUser(User user)
 {
     using (var context = new NoteDBContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Example #7
0
 public static void AddNote(Note note)
 {
     using (var context = new NoteDBContext())
     {
         note.DeleteDatabaseValues();
         context.Notes.Add(note);
         context.SaveChanges();
     }
 }
Example #8
0
 public static void DeleteNote(Note selectedNote)
 {
     using (var context = new NoteDBContext())
     {
         selectedNote.DeleteDatabaseValues();
         context.Notes.Attach(selectedNote);
         context.Notes.Remove(selectedNote);
         context.SaveChanges();
     }
 }