I'm building an application form, and have three models currently setup to handle all the data and are linked with my DBMS.
ApplicationSubmission.cs
: this contains a ID, character name & a date added fieldApplicationQuestion.cs
: this contains the data structure and pulls through the questions from the database, which I'll be using to display on the front-end of the siteApplicationAnswer.cs
: this contains an ID, application_id, question_id & answer field. application_id & question_id need to link with the ID's in the above two models.
ApplicationSubmission.cs
public partial class ApplicationSubmission
{
public long id { get; set; }
[Column(TypeName = "text")]
public string character_name { get; set; }
public DateTime? date_added { get; set; }
}
ApplicationQuestion.cs
public partial class ApplicationQuestion
{
public int id { get; set; }
[Column(TypeName = "text")]
public string question { get; set; }
[Column(TypeName = "text")]
public string description { get; set; }
}
ApplicationAnswer.cs
public partial class ApplicationAnswer
{
public int id { get; set; }
public int application_id { get; set; }
public int question_id { get; set; }
[Column(TypeName = "text")]
public string answer { get; set; }
}
My question is: how would I go about implementing these in the razor view, so that I can pull through the question name / description, but have the posted data go into a new ApplicationAnswer object, but reference the question_id that it's related to?