セレモニーモデルがあり、ID、日付があります。
今日の日付<=の式典が欲しいです。
これはサービスクラスの私の関数です。
public virtual IList<Ceremony> GetAllCeremonyByDate(DateTime currentDate)
{
var query = from c in _ceremonyRepository.Table
where c.ceremony_date >= currentDate
select c;
var countries = query.ToList();
return countries;
}
これは私のコントローラーです。
public ActionResult DetailForm()
{
Ceremony model = new Ceremony();
var ceremonyDate = _ceremonyService.GetAllCeremonyByDate(DateTime.Now);
if (ceremonyDate.Count == 0)
return Content("No ceremony can be loaded");
if (ceremonyDate.Count > 0)
{
foreach (var c in ceremonyDate)
// My problem
}
return View(model);
}
モデルに値を割り当てる方法がわかりません。