public async Task <IActionResult> Create([Bind("CategoryId,CategoryName,CategoryDescription")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("ProductId,Name,Description,Price,ImageUrl,ImageThumbnailUrl,IsOnSale,CategoryId")] Product product) { product.DateAdded = DateTime.Now; if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }