public async Task <ActionResult> PostCartProductDetail([FromBody] CartProduct product) { product.ProductId = (await _productService.Get(m => m.Name == product.Product.Name)).FirstOrDefault().Id; product.Product.Name = ""; await _cartproductService.Add(product); return(CreatedAtAction("GetCartProductDetail", new { id = product.Id }, product)); }
public IActionResult AddProductToChart(int Amount, long pId) { if (Amount == 0) { return(RedirectToAction("Index")); } _cartProductService.Add(new CartProduct { CartId = _cartService.GetUserCart().Id, ProductId = pId, OnCartAmount = Amount }); if (_cartProductService.SaveChanges() != 0) { return(RedirectToAction("Index", new { scsMsg = "Ürün başarılı bir şekilde sepete eklendi." })); } return(RedirectToAction("Index", new { scsMsg = "Ürün eklenirken bir hata oluştu." })); }