I want to get all the student have the ContractStatus == "Pending" in foreach and make a link to Edit the student
<div class="row">
@{ foreach (var studentCohort in ViewBag.CohortSubscriptionId)
{
<div class="col-md-5">
@{
var link = Html.ActionLink((string) studentCohort.ContractStatus, "Edit", "CohortSubscriptions", new { id = (object) studentCohort.ContractStatus }, new { @class ="form-control"});
var contractStatus = studentCohort.ContractStatus == "Pending" ? link : studentCohort;
}
@studentCohort.FullName (@studentCohort.contractStatus)
</div>
}
}
</div>
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Cohorts cohorts = db.Cohorts.Find(id);
if (cohorts == null)
{
return HttpNotFound();
}
var studentByCohort = db.Enrolled_Students.Where(x => x.CohortId == id).Select(x => new StudentCohortViewModel
{
CohortId = x.CohortId,
FirstName = x.FirstName,
LastName = x.LastName,
ContractStatus = x.ContractStatus
}).Distinct().ToList();
ViewBag.CohortSubscriptionId = studentByCohort;
return View(cohorts);
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''CodeboxxSchoolPortal.Models.StudentCohortViewModel' does not contain a definition for 'contractStatus''