Since the remarks are related to the employee rather than the document, you'll need to create a view-model containing the remarks and the list of documents.
For example:
public class EmployeeInformation
{
public int EmployeeId { get; set; }
public string? HrRemarks { get; set; }
public List<EmployeeDocument> Documents { get; set; }
}
public class EmployeeDocument
{
public string Filename { get; set; }
public string Filevalues { get; set; }
public IFormFile File { get; set; }
}
public async Task<IActionResult> DocumentValidate(int? id)
{
if (id == null || _context.EmpDocs == null)
{
return NotFound();
}
var employeeInfo = await _context.EmployeeBasicInformations.FindAsync(id);
if (employeeInfo == null)
{
return NotFound();
}
var docInfo = await _context.EmpDocs.FindAsync(id);
if (docInfo == null)
{
return NotFound();
}
var model = new EmployeeInformation()
{
EmployeeId = employeeInfo.EmployeeId,
HrRemarks = docInfo.HrRemarks,
};
string foldername = employeeInfo.EmployeeEmail;
string dirPath = Configuration["FolderPath:Document_Path"];
string path = Path.Combine(dirPath, foldername);
string[] files = Directory.GetFiles(path);
model.Documents = new List<EmployeeDocument>(files.Length);
foreach (string filePath in files)
{
model.Documents.Add(new EmpDoc
{
Filename = Path.GetFileName(filePath),
Filevalues = Path.GetFileNameWithoutExtension(filePath)
});
}
return View(model);
}
@model EmployeeInformation
<div class="container" style="padding: 0; height: 100%; width: 100%; margin: 0">
<table class="table table-bordered table-striped">
<thead>
<tr style="text-align: center">
<th>File Name</th>
<th>Download</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.Documents.Count; i++)
{
var file = Model.Documents[i];
<tr style="text-align: center">
<td></td>
<td>@files.Filename</td>
<td class="text-nowrap"><a asp-action="DownloadFile" asp-route-filename="@file.Filename" asp-route-id="@Model.EmployeeId">Download</a></td>
</tr>
}
</tbody>
</table>
<div>
Comments:
@Model.HrComments
</div>
</div>