Я хочу создать новый объект со ссылкой FK на объект в другой таблице. Это просто простое представление create, но я не знаю, как ссылаться на сущность Research с ID == id.
public ActionResult Create(int id)
{
SurveyPaper surveyPaper = new SurveyPaper();
return View(surveyPaper);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(int id, FormCollection collection)
{
var surveyPaper = new SurveyPaper();
try {
UpdateModel(surveyPaper);
surveyPaper.Research.ResearchID = id;
_r.AddSurveyPaper(surveyPaper);
return RedirectToAction("Details", new { id = surveyPaper.SurveyPaperID });
}
catch {
return View(surveyPaper);
}
}