public IActionResult DeleteConfirmed(int id) { var thisProduct = productRepo.Products.First(products => products.ProductId == id); productRepo.Remove(thisProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(Product product) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); product.User = currentUser; _db.Products.Add(product); _db.SaveChanges(); return(RedirectToAction("Index", "Products")); }
public Product Save(Product product) { db.Products.Add(product); db.SaveChanges(); return(product); }
public Review Save(Review review) { db.Reviews.Add(review); db.SaveChanges(); return(review); }