Exemplo n.º 1
0
        public string RemoveCartProduct()
        {
            int          productId    = -1;
            string       productColor = "";
            string       productSize  = "";
            MemoryStream stream       = new MemoryStream();

            Request.Body.CopyTo(stream);
            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                string requestBody = reader.ReadToEnd();
                if (requestBody.Length > 0)
                {
                    var obj = JsonConvert.DeserializeObject <PostData>(requestBody);
                    if (obj != null)
                    {
                        productId    = int.Parse(obj.productId);
                        productColor = obj.productColor;
                        productSize  = obj.productSize;
                    }
                }
            }
            CartProductManager.removeProduct(productId, productColor, productSize);
            double totalPrice = CartProductManager.getTotalPrice();

            if (CartProductManager.getCount() == 0)
            {
                return("empty");
            }
            else
            {
                return("" + totalPrice);
            }
        }