public async Task <ActionResult <QuestionSetDataset> > GetQuestionSet([FromRoute] int id)
        {
            QuestionSetDataset result = await _qService.GetQuestionSet(id);

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound());
        }
Beispiel #2
0
        public async Task <QuestionSetDataset> GetQuestionSet(string setName)
        {
            QuestionSetDataset result = null;
            QuestionSet        set    = await _uow.QuestionSetRepository.GetFirst(filter : set => set.SetName == setName, includeProperties : "SectionType");

            if (set != null)
            {
                IEnumerable <Models.Question> questions = await _uow.QuestionRepository.Get(filter : q => q.SetId == set.SetId);

                result           = _mapper.Map <QuestionSetDataset>(set);
                result.Questions = _mapper.Map <List <QuestionDataset> >(questions);
                result.SectionType.SectionTypeName = (await _uow.TranslationRepository.GetFirst(filter: type => type.SectionTypeId == result.SectionType.SectionTypeId && type.Language == "en")).Text;
            }
            return(result);
        }
        public async Task <ActionResult> UpdateSet([FromRoute] int id, [FromBody] QuestionSetParam param)
        {
            if (id != param.SetId)
            {
                return(Forbid());
            }
            QuestionSetDataset temp = await _qService.GetQuestionSet(param.SetName);

            if (temp != null && temp.SetId != param.SetId)
            {
                return(Conflict());
            }
            if (await _qService.UpdateQuestionSet(param))
            {
                return(NoContent());
            }
            return(BadRequest());
        }