public async Task <IActionResult> Create([Bind("BookId,Title,Author,CopyrightYear,ISBN,ImageUrl")] Book book) { if (ModelState.IsValid) { _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(book)); }
public async Task <IActionResult> Create(Sale sale) { //sale.Book = _context.Books.Find(sale.Book.BookId); if (ModelState.IsValid) { sale.Member = _context.Members.Find(_userManager.GetUserId(User)); sale.Book = _context.Books.Find(sale.Book.BookId); sale.Id = 0; _context.Add(sale); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sale)); }