public IHttpActionResult TestAnswer(TestAnswerModel data) { //get user Id var userWithClaims = (ClaimsPrincipal)User; var userCo = Convert.ToInt64(userWithClaims.Claims.First(c => c.Type == "userId").Value); var result = new Response(); try { var res = ClsDatabase.ExecuteDatatableSP("SPCHTTestSaveResult", ClsDatabase.GenParameters("@SignalCo", data.TestId, "@UserCo", userCo, "@Res", data.Answer), 1); result.Code = (int)ResponseType.Ok; if (result.Code == 200) { result.Message = "Success"; } result.Data = res.Rows[0].Table; return(Ok(result)); } catch (Exception e) { string ex = e.InnerException.ToString(); result.Code = 400; result.Message = "Server error"; return(Ok(result)); } }
public TestPassingAnswerModel(TestAnswerModel answerModel, int questionType) { Id = answerModel.Id; QuestionType = questionType; Content = answerModel.Content; IsSelected = false; CorrectnessIndicator = answerModel.СorrectnessIndicator; }
public void Update(int id, [FromBody] TestAnswerModel value) { var existingTestAnswer = testAnswers.Find(id); if (existingTestAnswer != null) { existingTestAnswer.Content = value.Content; existingTestAnswer.N_QuestionId = value.QuestionId; db.SaveChanges(); } }
public TestResultServiceTestBase() { testModel = new TestModel(); testAnswerModel = new TestAnswerModel(testModel); testWrongAnswerModel = new TestWrongAnswerModel(testModel); }
public static TestAnswer TestAnswerModelToTestAnswer(TestAnswerModel value) { return(new TestAnswer { Id = value.Id, Content = value.Content, N_QuestionId = value.QuestionId }); }
public void Add([FromBody] TestAnswerModel value) { testAnswers.Add(TestAnswerConverter.TestAnswerModelToTestAnswer(value)); db.SaveChanges(); }