想請問我該如何把這些資料傳給前端並顯示?
controller
var x = HisSrv.FindAkHistoryLastThreeTimes(model.DocOrder.PATNO);
FindAkHistoryLastThreeTimes方法
public List<OpdHistoryModel> FindAkHistoryLastThreeTimes(string PatNo)
{
return hisRepository.GetAkHistoryLastThreeTimes(PatNo);
}
我想顯示的前端
@Html.TextAreaFor(m => m.DocOrder.NOTE, new { @class = "form-control", @rows = "8", @style = "width:100%;"})
Controller:
public class YourController : Controller
{
private IHisSrv HisSrv { get; set; }
public YourController(IHisSrv hisSrv)
{
HisSrv = hisSrv;
}
public ActionResult YourAction(YourModel model)
{
var akHistory = HisSrv.FindAkHistoryLastThreeTimes(model.DocOrder.PATNO);
List<string> historyList = new List<string>();
foreach (var item in akHistory)
{
historyList.Add($"{item.VisitDate}: {item.Diagnosis}");
}
model.DocOrder.NOTE = string.Join("\n", historyList);
return View(model);
}
}
View:
@model YourProject.Models.YourModel
@Html.TextAreaFor(m => m.DocOrder.NOTE, new { @class = "form-control", @rows = "8", @style = "width:100%;"})