public async Task <IActionResult> Create([Bind("BookID,PublishedDate,UniqueID,Title,Author,Description,Price,Cost,Reordered,PurchaseCount,CopiesOnHand,LastOrdered")] Book book) { if (ModelState.IsValid) { //Generate next course number book.UniqueID = GenerateUniqueID.GetNextUniqueID(_context); _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(book)); }
public async Task <IActionResult> Create([Bind("BookID,PublishedDate,UniqueID,Title,Description,Price,Author,Cost,Reorder,CopiesOnHand,LastOrdered,Active")] Book book, int SelectedGenre) { book.UniqueID = GenerateUniqueID.GetNextUniqueID(_context); book.PublishedDate = System.DateTime.Today; book.Genre = _context.Genres.Find(SelectedGenre); if (ModelState.IsValid) { _context.Add(book); await _context.SaveChangesAsync(); _context.Update(book); return(RedirectToAction(nameof(Index))); } return(View(book)); }