public async Task <IActionResult> AddToBasket(int id, int quantity = 1) { // get product details var product = await _basketViewModelService.GetProductDetails(id); // get/create user id string userId = GetOrCreateUserId(); // create basket if not exists and get basket id int basketId; if (!await _basketService.BasketExistsAsync(userId)) { basketId = await _basketService.CreateBasketAsync(userId); } else { basketId = await _basketService.GetBasketIdAsync(userId); } // add item to the basket int count = await _basketService.AddItemToBasketAsync(basketId, product.Id, product.Price, quantity); return(Json(new { BasketItemCount = count })); }
public IActionResult AddToBasket(int id, int quantity = 1) { // todo: ilgili ürünü getir var product = _basketViewModelService.GetProductDetails(id); //get/create user id string userId = GetOrCreateUserId(); // todo: sepet yoksa oluştur // todo: oluşan sepete ilgili ürün ekle return(Json(new { BasketItemCount = 0 })); }