Пример #1
0
        public static List<Gallery> RetrieveAll()
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_Gallery WHERE pageWorkFlowState != 4 ORDER BY name";
            SqlCommand getGalleries = new SqlCommand(queryString, conn);

            SqlDataReader m_Galleries = getGalleries.ExecuteReader();

            List<Gallery> myGalleries = new List<Gallery>();

            while(m_Galleries.Read())
            {
                Gallery tempGallery = new Gallery();

                tempGallery.Id = m_Galleries.GetInt32(0);
                tempGallery.Name = m_Galleries.GetString(1);
                tempGallery.ContentGroup = m_Galleries.GetInt32(2);

                myGalleries.Add(tempGallery);
            }

            conn.Close();

            return myGalleries;
        }
Пример #2
0
        public void Update(Gallery m_Gallery, string OldName)
        {
            DBGallery.Update(m_Gallery);

            if (m_Gallery.Name != OldName)
            {
                string source = ConfigurationManager.AppSettings["Gallery"] + "\\" + OldName;
                string destination = ConfigurationManager.AppSettings["Gallery"] + "\\" + m_Gallery.Name;
                Directory.Move(source, destination);
            }
        }
Пример #3
0
        public static void Create(Gallery m_Gallery)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "INSERT INTO CMS_Gallery(name, contentGroup) VALUES(@name, @contentGroup)";
            SqlCommand insertGallery = new SqlCommand(queryString, conn);
            insertGallery.Parameters.AddWithValue("name", m_Gallery.Name);
            insertGallery.Parameters.AddWithValue("contentGroup", m_Gallery.ContentGroup);
            insertGallery.ExecuteNonQuery();

            conn.Close();
        }
Пример #4
0
        public ActionResult AddGallery(Gallery m_Gallery)
        {
            ViewBag.myContentGroups = Utility.ContentGroups();

            if (ModelState.IsValid)
            {
                GalleryRepository.CreateGallery(m_Gallery);
                return RedirectToAction("Index", "Gallery");
            }
            else
            {
                return View("AddGallery", m_Gallery);
            }
        }
Пример #5
0
 public void CreateGallery(Gallery m_Gallery)
 {
     DBGallery.Create(m_Gallery);
     Directory.CreateDirectory(ConfigurationManager.AppSettings["Gallery"] + "\\" + m_Gallery.Name);
     Directory.CreateDirectory(ConfigurationManager.AppSettings["Gallery"] + "\\" + m_Gallery.Name + "\\thumbs");
 }
Пример #6
0
 public ActionResult AddGallery()
 {
     ViewBag.myContentGroups = Utility.ContentGroups();
     Gallery m_Gallery = new Gallery();
     return View("AddGallery", m_Gallery);
 }
Пример #7
0
        public ActionResult EditGallery(Gallery m_Gallery, string OldName)
        {
            ViewBag.myContentGroups = Utility.ContentGroups();

            if (ModelState.IsValid)
            {
                GalleryRepository.Update(m_Gallery, OldName);
                return RedirectToAction("Index", "Gallery");
            }
            else
            {
                return View("EditGallery", m_Gallery);
            }
        }
Пример #8
0
        public static Gallery RetrieveOne(int id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_Gallery WHERE id = @id AND pageWorkFlowState != 4";
            SqlCommand getGallery = new SqlCommand(queryString, conn);
            getGallery.Parameters.AddWithValue("id", id);

            SqlDataReader m_Gallery = getGallery.ExecuteReader();

            Gallery myGallery = new Gallery();

            if(m_Gallery.Read())
            {
                myGallery.Id = m_Gallery.GetInt32(0);
                myGallery.Name = m_Gallery.GetString(1);
                myGallery.ContentGroup = m_Gallery.GetInt32(2);
            }

            conn.Close();

            return myGallery;
        }
Пример #9
0
        public static void Update(Gallery m_Gallery)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "UPDATE CMS_Gallery SET name = @name, contentGroup = @contentGroup WHERE id = @id";
            SqlCommand updateGallery = new SqlCommand(queryString, conn);
            updateGallery.Parameters.AddWithValue("name", m_Gallery.Name);
            updateGallery.Parameters.AddWithValue("contentGroup", m_Gallery.ContentGroup);
            updateGallery.Parameters.AddWithValue("id", m_Gallery.Id);

            updateGallery.ExecuteNonQuery();

            conn.Close();
        }