Beispiel #1
0
        public async Task <ActionResult> Create()
        {
            var model = new QuestionarioPerguntaDto();

            using (var cliente = Api.CriaCliente())
            {
                model.Perguntas = cliente.GetPerguntasAsync().Result.Select(a => new PerguntaItemDto()
                {
                    Descricao = a.Descricao, IdPergunta = a.Id
                }).ToList();;
            }

            return(View(model));
        }
        public async Task <ActionResult> PostQuestionarioAsync([FromBody] QuestionarioPerguntaDto dados)
        {
            var idUsuario = User.GetUserId();

            var questionario = new Questionario
            {
                Nome = dados.Descricao,
                QuestionarioPergunta = dados.Perguntas.Select(a => new QuestionarioPergunta()
                {
                    IdPergunta = a.IdPergunta
                }).ToList()
            };

            db.Questionario.Add(questionario);

            await db.SaveChangesAsync();

            return(NoContent());
        }
Beispiel #3
0
        public async Task <ActionResult> Create(QuestionarioPerguntaDto questionario)
        {
            if (ModelState.IsValid)
            {
                using (var cliente = Api.CriaCliente())
                {
                    await cliente.PostQuestionarioAsync(new ColetaApi.Models.QuestionarioPerguntaDto()
                    {
                        Perguntas = questionario.SelectedPerguntas.Select(p => new ColetaApi.Models.PerguntaSelecionadaDto()
                        {
                            IdPergunta = int.Parse(p)
                        }).ToList(),
                        Descricao = questionario.Descricao
                    });
                }
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Beispiel #4
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dados'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PostQuestionarioAsync(this IColetaApiClient operations, QuestionarioPerguntaDto dados = default(QuestionarioPerguntaDto), CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.PostQuestionarioWithHttpMessagesAsync(dados, null, cancellationToken).ConfigureAwait(false);
 }
Beispiel #5
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='dados'>
 /// </param>
 public static void PostQuestionario(this IColetaApiClient operations, QuestionarioPerguntaDto dados = default(QuestionarioPerguntaDto))
 {
     Task.Factory.StartNew(s => ((IColetaApiClient)s).PostQuestionarioAsync(dados), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }