public bool UpdateNote(Note note) { using var db = new SovaDbContext(); if (NoteExcist(note.Id)) { db.Notes.Update(note); return(db.SaveChanges() > 0); } return(false); }
public bool UpdateUser(AppUser user) { using var db = new SovaDbContext(); if (UserExcist(user.Email)) { db.AppUsers.Update(user); return(db.SaveChanges() > 0); } return(false); }
public bool DeleteNoteById(int noteId) { using var db = new SovaDbContext(); var note = db.Notes.Find(noteId); if (note == null) { return(false); } db.Notes.Remove(note); return(db.SaveChanges() > 0); }
public bool DeleteSearchHistoryById(int historyId) { using var db = new SovaDbContext(); var history = db.SearchHistories.Find(historyId); if (history == null) { return(false); } db.SearchHistories.Remove(history); return(db.SaveChanges() > 0); }
public bool DeleteUserByEmail(string useremail) { using var db = new SovaDbContext(); var email = db.AppUsers.Find(useremail); if (email == null) { return(false); } db.AppUsers.Remove(email); return(db.SaveChanges() > 0); }
public Note CreateNote(Note note) { using var db = new SovaDbContext(); db.Notes.Add(note); int changes = db.SaveChanges(); if (changes > 0) { return(note); } else { return(null); } }
public bool DeleteSearchHistoryByUserEmail(string userEmail) { using var db = new SovaDbContext(); var history = db.SearchHistories.Where(u => u.Email == userEmail); if (history == null) { return(false); } foreach (var item in history) { db.SearchHistories.Remove(item); } return(db.SaveChanges() > 0); }
public SearchHistory CreateSearchHistory(SearchHistory history) { using var db = new SovaDbContext(); db.SearchHistories.Add(history); int changes = db.SaveChanges(); if (changes > 0) { return(history); } else { return(null); } }
public AppUser CreateUser(string name, string email, string password, string salt) { using var db = new SovaDbContext(); var user = new AppUser() { Name = name, Email = email, Password = password, Salt = salt }; db.AppUsers.Add(user); int changes = db.SaveChanges(); if (changes > 0) { return(user); } else { return(null); } }