public FilesViewModel GetFile(string fileID)
        {
            Files file = db.Files.Find(Int32.Parse(fileID));            
            FilesViewModel v = new FilesViewModel();

            v.CID = file.CID;
            v.Class = file.Class;
            v.FileID = file.FileID;
            v.FileAddr = file.FileAddr;
            v.FileName = file.FileName;

            return v;
        }
        public IQueryable<FilesViewModel> ReadFilesList(int Cid, int Class)
        {
            List<FilesViewModel> ret = new List<FilesViewModel>();

            var qryF = db.Files.Where(x => x.CID == Cid && x.Class == Class);
            foreach (Files f in qryF)
            {
                FilesViewModel v = new FilesViewModel();

                v.CID = f.CID;
                v.Class = f.Class;
                v.FileID = f.FileID;

                if (f.Class == 9)
                {
                    v.FileAddr = f.FileAddr;
                    v.FileName = f.FileName;
                }
                else if (f.Class == 3)
                {
                    v.FileAddr = db.KnowledgeBase.AsEnumerable().Where(x => x.KnowledgeID == f.KnowledgeID).Select(x => x.FileAddr).First();
                    v.FileName = db.KnowledgeBase.AsEnumerable().Where(x => x.KnowledgeID == f.KnowledgeID).Select(x => x.FileName).First();
                }
                else
                {
                    v.FileAddr = "/Home/GetFile?FileID=" + f.FileID.ToString();
                    v.FileName = f.FileName;
                }
                

                ret.Add(v);
            }
            return ret.AsQueryable();
        }
        public IQueryable<FilesViewModel> ReadPageFilesList(int PageID)
        {
            List<FilesViewModel> ret = new List<FilesViewModel>();

            var qryF = db.PageFiles.Where(x => x.PageID == PageID);
            foreach (PageFiles f in qryF)
            {
                FilesViewModel v = new FilesViewModel();

                v.CID = f.PageID;
                v.FileID = f.FileID;
                //v.FileAddr = f.FileAddr;
                v.FileAddr = "/Home/GetPageFile?FileID=" + f.FileID.ToString();
                v.FileName = f.FileName;

                ret.Add(v);
            }
            return ret.AsQueryable();
        }