I have ceremony Model and it has id, date.
I want to get ceremonies which are date<= today.
This is my function in service class.
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;
}
This is my controller.
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);
}
I don't know how to assign value to model.