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

            if (result != null)
            {
                return(Ok(result));
            }
            return(NotFound());
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        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());
        }