I want to create new object with the FK reference on the entity in onother table. It's just a simple create view but i don't know how to reference the Research entity with 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);
}
}