public ActionResult ViewStudentUploads(string teacherFolder, string homeworkFolder, string studentFolder, string path) { string realPath; if ((Request.QueryString["teacherFolder"] != Session["SessionUser"] + "_" + Session["SessionUserId"]) || (Request.QueryString["teacherFolder"] == null)) { return(View("Error", "You do not have the right to access this folder!")); } realPath = ConfigurationManager.AppSettings["BasePath"] + teacherFolder + "/"; if (homeworkFolder != null) { realPath += homeworkFolder + "/"; } if (studentFolder != null) { realPath += studentFolder + "/"; } if (path != null) { realPath += path; } ExplorerModelVM ex = new ExplorerModelVM(); if (homeworkFolder == null) { ex = fileSystemService.GetExplorerModel(realPath, Request.Url); } else { ex = fileSystemService.GetExplorerModel(realPath, Request.Url, Convert.ToInt32(homeworkFolder.Split('_')[1])); } if (!ex.isFile) { return(View(ex)); } else { string fileText = ""; try { fileText = fileSystemService.GetFileText(realPath); } catch (Exception) { } return(View("ViewStudentHomework", (object)fileText)); } }
public ExplorerModelVM GetExplorerModel(string path, Uri requestURL, int?homeworkID = null) { ExplorerModel model = manager.GetExplorerModel(path, requestURL); ExplorerModelVM vm = new ExplorerModelVM(); vm.dirModelList = new List <Models.DirModel>(); foreach (ServiceHelpers.Model.DirModel item in model.dirModelList) { if (homeworkID != null) { vm.dirModelList.Add( new BusinessLayer.Models.DirModel() { DirAccessed = item.DirAccessed, DirName = item.DirName, Deadline = homeworkRepository.GetHomework((int)homeworkID).Deadline }); } else { vm.dirModelList.Add( new BusinessLayer.Models.DirModel() { DirAccessed = item.DirAccessed, DirName = item.DirName, Deadline = homeworkRepository.GetHomework(Convert.ToInt32(item.DirName.Split('_')[1])).Deadline }); } } vm.fileModelList = new List <Models.FileModel>(); foreach (ServiceHelpers.Model.FileModel item in model.fileModelList) { vm.fileModelList.Add(new BusinessLayer.Models.FileModel() { FileAccessed = item.FileAccessed, FileName = item.FileName, FileSizeText = item.FileSizeText }); } vm.isFile = model.isFile; return(vm); }