Пример #1
0
        public JsonResult AddSubProductProperty(string propName, int subCatId)
        {
            int propId = DataProvider.AddSubProductProperty(subCatId, propName);
            SubProductProperty prop = new SubProductProperty()
            {
                Id = propId,
                Name = propName
            };
            string html = this.RenderPartialToString("Partials/_SubProductPropRow", prop);

            return Json(new { html = html });
        }
Пример #2
0
        public static List<SubProductProperty> GetSubProductProperties(int subCatId)
        {
            List<SubProductProperty> props = new List<SubProductProperty>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[CONNECTION_STRING].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetProductProperties", conn))
                {
                    cmd.Parameters.Add(new SqlParameter("@SubProductId", subCatId));

                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            SubProductProperty p = new SubProductProperty();
                            p.Id = reader.GetInt32(1);
                            p.Name = reader.GetString(0);
                            props.Add(p);
                        }
                    }

                    conn.Close();
                }
            }

            return props;
        }