public HttpResponseMessage GetQuestionBank(int id)
        {
            QuestionBank questionbank;

            try
            {
                if (ModelState.IsValid)
                {
                    questionbank = _blquestionbank.GetQuestionBankDetails(id);

                    if (questionbank == null)
                    {
                        log.Error("Requested data not found.");
                        return(Request.CreateResponse(HttpStatusCode.NotFound));
                    }

                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, questionbank));
                    }
                }
                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));
            }
        }
Example #2
0
        public void QuestionBankGetDetails()
        {
            validation.GetQuestionBankDetails(questionBankList[0].QuestionBankID).Returns(questionBankList[0]);
            questionBankController.Request       = new HttpRequestMessage();
            questionBankController.Configuration = new HttpConfiguration();
            var actionResult = questionBankController.GetQuestionBank(questionBankList[0].QuestionBankID);

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