예제 #1
0
        public IActionResult Get(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var questionType = _service.Get(d => d.Id == id);

            return(Ok(questionType));
        }
예제 #2
0
        public ActionResult Details(int?id)
        {
            try
            {
                QuestionTypeDTO questionTypeDTO = QuestionTypeService.Get(id);
                QuestionTypeVM  questionTypeVM  = Mapper.Map <QuestionTypeVM>(questionTypeDTO);

                return(View(questionTypeVM));
            }
            catch (ArgumentException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
        }
예제 #3
0
        public ActionResult QuestionAnswers(int questionTypeId)
        {
            try
            {
                ViewBag.Sections = Mapper.Map <IEnumerable <QuestionTypeVM> >(QuestionTypeService.GetAll().ToList());
                ViewBag.Section  = QuestionTypeService.Get(questionTypeId).Name;
                var formDataDTOs = QuestionAnswerService.GetQuestionAnswersByQuestionType(questionTypeId).ToList();
                var formDataVMs  = Mapper.Map <IEnumerable <FormDataVM> >(formDataDTOs);
                //IEnumerable<AnswerVM> answerVMs = Mapper.Map<IEnumerable<AnswerVM>>(answerDTOs);

                return(View(formDataVMs));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }