コード例 #1
0
 public void AddBookmark(Bookmark b)
 {
     using (var context = new UserBookmarkContext(_conn))
     {
         context.Bookmarks.Add(b);
         context.SaveChanges();
     }
 }
コード例 #2
0
 public void Update(Bookmark b)
 {
     using (var context = new UserBookmarkContext(_conn))
     {
         context.Bookmarks.Update(b);
         context.SaveChanges();
     }
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
        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();
                }
            }
        }