public async Task <IActionResult> Files([FromRoute] int ReferenceID) { var result = new List <ResultLoadImage>(); if (_appSettings.UploadFileToDataBase == "0") { var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "Upload"); if (Directory.Exists(uploads)) { int key = 0; var provider = _hostingEnvironment.ContentRootFileProvider; foreach (string fileName in Directory.GetFiles(uploads)) { var fileInfo = provider.GetFileInfo(fileName); result.Add(new ResultLoadImage(++key, 0, fileInfo.Name)); } } return(Ok(result)); } else { var obj = await _attachmentRepository.FindAllAsync(p => p.ReferenceID == ReferenceID); foreach (var fileInfo in obj) { result.Add(new ResultLoadImage(fileInfo.AttachmentID, fileInfo.ReferenceID, fileInfo.FileName)); } return(Ok(result)); } //Dictionary<int, string> result = new Dictionary<int, string>(); }