public async Task <IActionResult> Create([Bind("CategoryId,CategoryName,Description")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("CatId,Name,DateOfBirth,ShortDescription,LongDescription,Price,ImageUrl,ImageThumbnailUrl,IsPreferredCat,InStock,CategoryId")] Cat cat) { if (ModelState.IsValid) { _context.Add(cat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryName", cat.CategoryId); return(View(cat)); }