Пример #1
0
        public JsonResult AddBanner(string title, string subTitle, string filename)
        {
            int orderId;
            int id = DataProvider.InsertHomeBanner(title, subTitle, filename, out orderId);
            BennerGalleryItem banner = new BennerGalleryItem()
            {
                Id = id,
                OrderId = orderId,
                ImageName = filename,
                Title = title,
                SubTitle = subTitle
            };

            string html = this.RenderPartialToString("Partials/_HomeBannerRow", banner);

            return Json(new { success = true, html = html });
        }
Пример #2
0
        public static List<BennerGalleryItem> GetBannersGallery()
        {
            List<BennerGalleryItem> banners = new List<BennerGalleryItem>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[CONNECTION_STRING].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetBannersGallery", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            BennerGalleryItem banner = new BennerGalleryItem()
                            {
                                Id = reader.GetInt32(0),
                                OrderId = reader.GetInt32(4),
                                Title = reader.GetString(1),
                                SubTitle = reader.GetString(2),
                                ImageName = reader.GetString(3)
                            };

                            banners.Add(banner);
                        }
                    }

                    conn.Close();
                }
            }

            return banners;
        }