Exemple #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());
     }
 }
Exemple #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));
     }
 }
Exemple #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));
     }
 }
Exemple #4
0
 public static bool UserExists(string login)
 {
     using (var context = new NoteDBContext())
     {
         return(context.Users.Any(u => u.Login == login));
     }
 }
Exemple #5
0
 public static void SaveNote(Note note)
 {
     using (var context = new NoteDBContext())
     {
         context.Entry(note).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #6
0
 public static void AddUser(User user)
 {
     using (var context = new NoteDBContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Exemple #7
0
 public static void AddNote(Note note)
 {
     using (var context = new NoteDBContext())
     {
         note.DeleteDatabaseValues();
         context.Notes.Add(note);
         context.SaveChanges();
     }
 }
Exemple #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();
     }
 }