public async Task <IActionResult> Create([Bind("Id,Name,CreateDate")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("Id,CategoryId,Name,Description,Content,CreateDate")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(await _context.Category.ToListAsync(), "Id", "Name", product.CategoryId); return(View(product)); }