public ActionResult Get(String FolderId) { User user = Session["User"] as User; int folderId = 1; if (FolderId != null) { folderId = Convert.ToInt32(FolderId); } if (user == null) { ResponseHelper.WriteNull(Response); } else { if (folderId == 1) { var fileList = FileBLL.GetRootByUserId(user.Id); var folderList = FolderBLL.GetRootByUserId(user.Id); var dataList = new List <DataList>(); foreach (var v in fileList) { dataList.Add(new DataList { Id = v.Id, Type = v.Type, Size = v.Size, UpdateTime = v.UpdateTime, Name = v.Name }); } foreach (var v in folderList) { dataList.Add(new DataList { Id = v.Id, Type = "Folder", Size = "-", UpdateTime = v.UpdateTime, Name = v.Name }); } ResponseHelper.WriteObject(Response, new { DataList = dataList }); } else { var fileList = FileBLL.GetByFolderId(folderId); var folderList = FolderBLL.GetByFolderId(folderId); var dataList = new List <DataList>(); foreach (var v in fileList) { dataList.Add(new DataList { Id = v.Id, Type = v.Type, Size = v.Size, UpdateTime = v.UpdateTime, Name = v.Name }); } foreach (var v in folderList) { dataList.Add(new DataList { Id = v.Id, Type = "Folder", Size = "-", UpdateTime = v.UpdateTime, Name = v.Name }); } ResponseHelper.WriteObject(Response, new { DataList = dataList }); } } return(null); }
public ActionResult Get() { if (Request["Id"] != null && Request["Id"] != "") { int id = Convert.ToInt32(Request["Id"]); File file = FileBLL.GetById(id); ResponseHelper.WriteObject(Response, "File", file); } if (Request["UserId"] != null && Request["UserId"] != "") { int userId = Convert.ToInt32(Request["UserId"]); IList <File> listFile = FileBLL.GetRootByUserId(userId); ResponseHelper.WriteList(Response, "FileList", listFile); } if (Request["FolderId"] != null && Request["FolderId"] != "") { int folderId = Convert.ToInt32(Request["FolderId"]); IList <File> filelst = FileBLL.GetByFolderId(folderId); ResponseHelper.WriteList(Response, "FileList", filelst); } ResponseHelper.WriteNull(Response); return(null); }