public HttpResponseMessage PutQuestionBank(QuestionBank questionbank)
        {
            int result = 0;

            try
            {
                if (ModelState.IsValid)
                {
                    result = _blquestionbank.UpdateQuestionBank(questionbank);
                    if (result > 0)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }

                    else
                    {
                        log.Error("Question bank failed to update");
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                    }
                }
                else
                {
                    log.Error("Invalid model state encountered.");
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Пример #2
0
        public void IsQuestionBankUpdated()
        {
            validation.UpdateQuestionBank(questionBankList[0]).Returns(1);
            questionBankController.Request       = new HttpRequestMessage();
            questionBankController.Configuration = new HttpConfiguration();

            questionBankList[0].Question = "UpdatedQuestionBank";
            var actionResult = questionBankController.PutQuestionBank(questionBankList[0]);

            Assert.AreEqual(HttpStatusCode.OK, actionResult.StatusCode);
        }