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