public FolderDetailsDto GetFolderDetails(string securityToken, long?idFolder) { try { var session = CheckSession(securityToken); FolderDetailsDto result = new FolderDetailsDto(); if (idFolder.HasValue) { result = Mapper.Map <FolderDetailsDto>(_dao.ReadFullFolder(idFolder.Value)); } else { result.Folders = Mapper.Map <List <FolderDto> >(_dao.GetFoldersInRoot(session.IdUser)); using (var fileService = new FileServices()) { result.Files = fileService.GetFilesInRoot(securityToken); } } return(result); } catch (FileSharingException) { throw; } catch (Exception e) { throw new FileSharingException(FileSharingException.ERROR_FILESHARING_SERVER, e.Message, e); } }
public IActionResult Index(int?id) { FolderDetailsDto result = new FolderDetailsDto(); try { ViewBag.FolderId = id; using (var srv = ServicesFactory.Folder) result = srv.GetFolderDetails(SecurityToken, id); if (id.HasValue) { FolderDto folder; using (var srv = ServicesFactory.Folder) folder = srv.Read(SecurityToken, id.Value); var idRoot = folder.IdFolderRoot; string path = ""; while (folder != null) { path = folder.Name + "/" + path; using (var srv = ServicesFactory.Folder) folder = folder.IdFolderRoot.HasValue ? srv.Read(SecurityToken, folder.IdFolderRoot.Value) : null; } ViewBag.LinkFolder = idRoot.HasValue ? idRoot + "," + path : path; } } catch (FileSharingException e) { _logger.LogError(e.Message); } return(View(result)); }