public bool UpdateCorrectAnswer(CorrectAnswerVM model) { var answer = _context.CorrectAnswer.Find(model.correctAnswerId); if (answer == null) { throw new Exception("Record not found"); } answer.QuestionBankId = model.questionBankId; answer.QuestionOptionId = model.questionOptionId; return(_context.SaveChanges() > 0); }
public HttpResponseMessage UpdateCurrectAnswer(CorrectAnswerVM model) { try { var response = _currentAnswer.UpdateCorrectAnswer(model); if (response == false) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "No record found" })); } return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = response })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = ex.Message })); } }
public bool AddCorrectAnswer(CorrectAnswerVM model) { if (model == null) { throw new Exception("There is no Entry!"); } var answer = new CorrectAnswer { QuestionBankId = model.questionBankId, QuestionOptionId = model.questionOptionId, QuestionOptionTypeId = model.questionOptionTypeId, }; _context.CorrectAnswer.Add(answer); return(_context.SaveChanges() > 0); }