Ejemplo n.º 1
0
        public JsonResult UpdateCartProduct(int orderId, int quantity, bool isChecked, string comment)
        {
            CartProduct cp = new CartProduct()
            {
                Comment = comment,
                IsChecked = isChecked,
                Quantity = quantity,
                OrderId = orderId
            };

            DataProvider.UpdateCartProduct(cp);

            return Json(new { });
        }
Ejemplo n.º 2
0
        public static List<CartProduct> GetCartProducts(int userId)
        {
            OrderDay orderDay = GetOrderDay(userId);
            List<CartProduct> products = new List<CartProduct>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[CONNECTION_STRING].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetProductsForCart", conn))
                {
                    cmd.Parameters.Add(new SqlParameter("@OrderDayId", orderDay.Id));
                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            CartProduct p = new CartProduct();
                            p.OrderId = reader.GetInt32(0);
                            p.Quantity = reader.GetInt32(1);
                            p.SKU = reader.GetString(5);
                            p.ProductId = int.Parse(reader.GetString(6));
                            p.Property = reader.GetString(7);
                            p.IsChecked = reader.GetBoolean(9);
                            p.Comment = reader.IsDBNull(12) ? string.Empty : reader.GetString(12);
                            p.Date = !reader.IsDBNull(11) ? reader.GetDateTime(11) : new DateTime(reader.GetInt32(4), reader.GetInt32(3), reader.GetInt32(2));
                            products.Add(p);
                        }
                    }

                    conn.Close();
                }
            }

            return products;
        }
Ejemplo n.º 3
0
        public static void UpdateCartProduct(CartProduct product)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[CONNECTION_STRING].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("UpdateProductCart", conn))
                {
                    cmd.Parameters.Add(new SqlParameter("@OrderId", product.OrderId));
                    cmd.Parameters.Add(new SqlParameter("@Quantity", product.Quantity));
                    cmd.Parameters.Add(new SqlParameter("@IsChecked", product.IsChecked));
                    cmd.Parameters.Add(new SqlParameter("@Comment", product.Comment));

                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }

            Cart.Products.ResetCart();
        }