public void AddBookmark(Bookmark b) { using (var context = new UserBookmarkContext(_conn)) { context.Bookmarks.Add(b); context.SaveChanges(); } }
public void Update(Bookmark b) { using (var context = new UserBookmarkContext(_conn)) { context.Bookmarks.Update(b); context.SaveChanges(); } }
public void Delete(int id) { using (var context = new UserBookmarkContext(_conn)) { var bmToDelete = context.Bookmarks.FirstOrDefault(b => b.Id == id); context.Bookmarks.Remove(bmToDelete); context.SaveChanges(); } }
public void AddUser(User u) { using (var context = new UserBookmarkContext(_conn)) { //add only if userName doesn't already exist var user = GetUserByEmail(u.Email); if (user is null) { u.PasswordHash = BCrypt.Net.BCrypt.HashPassword(u.PasswordHash);//encrypts the password value passed in context.Users.Add(u); context.SaveChanges(); } } }