public void Update(Folder m_Folder, string OldName)
        {
            DBFolder.Update(m_Folder);

            if (m_Folder.Name != OldName)
            {
                string path, OldPath;

                if (m_Folder.ParentId != 0)
                {
                    path = DBFolder.FolderPath(m_Folder.ParentId);
                    OldPath = path;
                    OldPath += "\\" + OldName;
                    path += "\\" + m_Folder.Name;
                }
                else
                {
                    path = m_Folder.Name;
                    OldPath = OldName;
                }

                string source = ConfigurationManager.AppSettings["Documents"] + "\\" + OldPath;
                string destination = ConfigurationManager.AppSettings["Documents"] + "\\" + path;
                Directory.Move(source, destination);
            }
        }
        public ActionResult AddFolder(int id = 0)
        {
            ViewBag.ParentId = id;

            Folder m_Folder = new Folder();

            return View("AddFolder", m_Folder);
        }
Exemple #3
0
        public static void Create(Folder m_Folder)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "INSERT INTO CMS_Folders(name, parentId) VALUES(@name, @parentId)";
            SqlCommand insertFolder = new SqlCommand(queryString, conn);
            insertFolder.Parameters.AddWithValue("name", m_Folder.Name);
            insertFolder.Parameters.AddWithValue("parentId", m_Folder.ParentId);

            insertFolder.ExecuteNonQuery();

            conn.Close();
        }
        public void Create(Folder m_Folder)
        {
            string path;
            DBFolder.Create(m_Folder);

            if (m_Folder.ParentId != 0)
            {
                path = DBFolder.FolderPath(m_Folder.ParentId);
                path += "\\" + m_Folder.Name;
            }
            else
            {
                path = m_Folder.Name;
            }

            Directory.CreateDirectory(ConfigurationManager.AppSettings["Documents"] + "\\" + path);
        }
        public static MvcHtmlString FolderBreadCrumb(this HtmlHelper html, int parentId)
        {
            string path = "";

            Folder m_Folder = new Folder();
            m_Folder = DBFolder.RetrieveOne(parentId);

            if (parentId == 0)
            {
                path = "Root";
            }
            else if (m_Folder.ParentId == 0)
            {
                path = "<a href='/Document/Index/0' >Root</a> > " + m_Folder.Name;
            }
            else
            {
                path = m_Folder.Name;
                path = "<a href='/Document/Index/0' >Root</a> > " + getFolderBreadCrumb(m_Folder.ParentId) + " > " + path;
            }

            MvcHtmlString m_String = new MvcHtmlString(path);
            return m_String;
        }
Exemple #6
0
        public static void Update(Folder m_Folder)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "UPDATE CMS_Folders SET name = @name, parentId = @parentId WHERE id = @id";
            SqlCommand updateFolder = new SqlCommand(queryString, conn);
            updateFolder.Parameters.AddWithValue("name", m_Folder.Name);
            updateFolder.Parameters.AddWithValue("parentId", m_Folder.ParentId);
            updateFolder.Parameters.AddWithValue("id", m_Folder.Id);
            updateFolder.ExecuteNonQuery();

            conn.Close();
        }
Exemple #7
0
        public static Folder RetrieveOne(int id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_Folders WHERE id = @id AND pageWorkFlowState != 4";
            SqlCommand getFolder = new SqlCommand(queryString, conn);
            getFolder.Parameters.AddWithValue("id", id);
            SqlDataReader folderDataReader = getFolder.ExecuteReader();

            Folder m_Folder = new Folder();

            if (folderDataReader.Read())
            {
                m_Folder.Id = folderDataReader.GetInt32(0);
                m_Folder.Name = folderDataReader.GetString(1);
                m_Folder.ParentId = folderDataReader.GetInt32(2);
            }

            conn.Close();
            return m_Folder;
        }
Exemple #8
0
        public static List<Folder> RetrieveAll(int id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

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

            SqlDataReader foldersDataReader = getFolders.ExecuteReader();

            List<Folder> m_Folders = new List<Folder>();

            while (foldersDataReader.Read())
            {
                Folder tempFolder = new Folder();
                tempFolder.Id = foldersDataReader.GetInt32(0);
                tempFolder.Name = foldersDataReader.GetString(1);
                tempFolder.ParentId = foldersDataReader.GetInt32(2);
                m_Folders.Add(tempFolder);
            }

            conn.Close();

            return m_Folders;
        }
 public ActionResult AddFolder(Folder m_Folder)
 {
     if (ModelState.IsValid)
     {
         FolderRepository.Create(m_Folder);
         return RedirectToAction("Index", "Document", new { id = m_Folder.ParentId });
     }
     else
     {
         ViewBag.ParentId = m_Folder.ParentId;
         return View("AddFolder", m_Folder);
     }
 }
        public ActionResult EditFolder(Folder m_Folder, string OldName)
        {
            ViewBag.OldName = OldName;

            if (ModelState.IsValid)
            {
                FolderRepository.Update(m_Folder, OldName);
                return RedirectToAction("Index", "Document", new { id = m_Folder.ParentId });
            }
            else
            {
                return View("EditFolder", m_Folder);
            }
        }