public async Task <IActionResult> Edit(int id, [Bind("UserId,MessageBody,MessageDate,ProductId")] UserProductComments userProductComments) { if (id != userProductComments.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userProductComments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserProductCommentsExists(userProductComments.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", userProductComments.ProductId); ViewData["UserId"] = new SelectList(_context.WebUsers, "UserId", "Address", userProductComments.UserId); return(View(userProductComments)); }
public async Task <IActionResult> Create([Bind("UserId,MessageBody,MessageDate,ProductId")] UserProductComments userProductComments) { if (ModelState.IsValid) { _context.Add(userProductComments); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", userProductComments.ProductId); ViewData["UserId"] = new SelectList(_context.WebUsers, "UserId", "Address", userProductComments.UserId); return(View(userProductComments)); }