public void DeleteFolder(CL_Document docForDelete)
        {
            if (docForDelete.isFolder)
            {
                // Remove the section item from the "all" observable collection.

                AllFolders.Remove(docForDelete);

                foreach (CL_Document DocForDelete in docForDelete.getContent())
                {
                    DeleteFolder(DocForDelete);
                }
                // Remove the section item from the data context.

                ClarolineDB.Documents_Table.DeleteOnSubmit(docForDelete);
            }
            else
            {
                // Remove the section item from the "all" observable collection.

                AllFiles.Remove(docForDelete);
                
                // Remove the section item from the data context.

                ClarolineDB.Documents_Table.DeleteOnSubmit(docForDelete);
            }
            // Save changes to the database.

            ClarolineDB.SubmitChanges();
        }
        private void UpdateFolder(CL_Document newDoc)
        {
            CL_Document foldInDb = (from CL_Document _fold in ClarolineDB.Documents_Table
                                  where _fold.Equals(AllFolders[AllFolders.IndexOf(newDoc)])
                                  select _fold).First();

            foldInDb.notifiedDate = newDoc.notifiedDate;
            foldInDb.date = newDoc.date;
            foldInDb.updated = newDoc.updated;

            ClarolineDB.SubmitChanges();

            AllFolders[AllFolders.IndexOf(foldInDb)].notifiedDate = newDoc.notifiedDate;
            AllFolders[AllFolders.IndexOf(foldInDb)].date = newDoc.date;
            AllFolders[AllFolders.IndexOf(foldInDb)].updated = newDoc.updated;

        }
        private void UpdateFile(CL_Document newFile)
        {
            CL_Document fileInDb = (from CL_Document _file in ClarolineDB.Documents_Table
                                  where _file.Equals(AllFiles[AllFiles.IndexOf(newFile)])
                             select _file).First();

            fileInDb.notifiedDate = newFile.notifiedDate;
            fileInDb.date = newFile.date;
            fileInDb.updated = newFile.updated;
            fileInDb.date = newFile.date;

            ClarolineDB.SubmitChanges();
            
            AllFiles[AllFiles.IndexOf(fileInDb)].notifiedDate = newFile.notifiedDate;
            AllFiles[AllFiles.IndexOf(fileInDb)].date = newFile.date;
            AllFiles[AllFiles.IndexOf(fileInDb)].updated = newFile.updated;
            AllFiles[AllFiles.IndexOf(fileInDb)].date = newFile.date;

            AddNotification(CL_Notification.CreateNotification(fileInDb, true));
        }
        public void AddDocument(CL_Document newDoc)
        {
            newDoc.updated = true;

            if (newDoc.isFolder)
            {
                if (!AllFolders.Contains(newDoc))
                {
                    // Add a to-do item to the data context.

                    ClarolineDB.Documents_Table.InsertOnSubmit(newDoc);

                    // Save changes to the database.

                    ClarolineDB.SubmitChanges();

                    // Add a to-do item to the "all" observable collection.

                    AllFolders.Add(newDoc);
                }
                else
                    UpdateFolder(newDoc);
            }
            else
            {
                if (!AllFiles.Contains(newDoc))
                {
                    // Add a to-do item to the data context.

                    ClarolineDB.Documents_Table.InsertOnSubmit(newDoc);
                    // Save changes to the database.

                    ClarolineDB.SubmitChanges();

                    // Add a to-do item to the "all" observable collection.

                    AllFiles.Add(newDoc);

                    AddNotification(CL_Notification.CreateNotification(newDoc, false));

                }
                else
                    UpdateFile(newDoc);
            }
        }