public IActionResult Get(int id) { if (!ModelState.IsValid) { return(BadRequest()); } var questionType = _service.Get(d => d.Id == id); return(Ok(questionType)); }
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()); } }
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)); } }