예제 #1
0
        public IActionResult DeleteConfirmed(int id)
        {
            var thisProduct = productRepo.Products.First(products => products.ProductId == id);

            productRepo.Remove(thisProduct);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        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"));
        }
예제 #3
0
 public Product Save(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
     return(product);
 }
예제 #4
0
 public Review Save(Review review)
 {
     db.Reviews.Add(review);
     db.SaveChanges();
     return(review);
 }