public ActionResult EditBook(Book Book) { try { Book updated_book = _db.Books.Find(Book.BookId); if (Book.Title != null) { updated_book.Title = Book.Title; } if (Book.AuthorId != null) { updated_book.AuthorId = Book.AuthorId; } // ViewData["Message"] = ViewData["Message"]+" "+ updated_book.BookId +" " + updated_book.Title + " " + updated_book.AuthorId; _db.Update(updated_book); _db.SaveChanges(); ModelState.Clear(); ViewData["Message"] = ViewData["Message"] + "1"; } catch { ViewData["Message"] = ViewData["Message"] + "0"; } return(View("../index/editbook")); }
public async void UpdatePassword(CetUser user, string newPassword) { string hashed = HashPassword(newPassword); user.Password = hashed; _context.Update(user); await _context.SaveChangesAsync(); }