0
프로젝트에서 MVC3-Viewmodel 모델을 먼저 사용하고 있습니다. 사용자가에 값을 입력MVC : 동일한 [HTTPOST] 동작 방법으로 편집 및 생성
내 DDL
및 TextArea
후이 basicly 지금 내 게시물의 조치 방법은 생성하고 저장, 내 POST 액션에 아약스 url.post를 실행 내 양식 버튼을 클릭합니다.
- 1 단계 :하지만 내가 원하는 검사, 예를 몇 가지 유형입니다 SelectQuestion 어떤 대답이있는 경우
- 2 단계 : 대답은 업데이 트를
- 3 단계를 할 수있는 경우 : 답이 존재하지 않는 경우 작성 새롭고 그것을 구하십시오.
이 내 컨트롤러가 지금과 같은 모습입니다 :
[HttpPost]
public JsonResult AnswerForm(int id, SelectedQuestionViewModel model)
{
bool result = false;
var goalCardQuestionAnswer = new GoalCardQuestionAnswer(); // Creates an instance of the entity that I want to fill with data
SelectedQuestion SelectedQ = answerNKIRepository.GetSelectedQuestionByID(model.QuestionID); // Retrieve SelectedQuestion from my repository with my QuestionID.
goalCardQuestionAnswer.SelectedQuestion = SelectedQ; // Filling my entity with SelectedQ
goalCardQuestionAnswer.SelectedQuestion.Id = model.QuestionID; // filling my foreign key with the QuestionID
goalCardQuestionAnswer.Comment = model.Comment; // Filling my entity attribute with data
goalCardQuestionAnswer.Grade = model.Grade; // Filling my entity attribute with data
answerNKIRepository.SaveQuestionAnswer(goalCardQuestionAnswer); // adding my object
answerNKIRepository.Save(); // saving
result = true;
return Json(result);
}
Comment
및 Grade
이 널 aswell이다.
entitys는
[Question](1)------(*)[SelectedQuestion](1)-----(0..1)[GoalCardQuestionAnswer]
도움의 어떤 종류의 평가처럼 연결되어 있습니다.
미리 감사드립니다.