public async Task <IActionResult> Create(Product product) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); product.Admin = currentUser; product.CreateDate = DateTime.Now; _db.Products.Add(product); _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(string author, string contentBody, int rating, int id) { var newReview = new Review(author, contentBody, rating, id); if (ModelState.IsValid) { _db.Reviews.Add(newReview); _db.SaveChanges(); } return(Json(newReview)); }