Esempio n. 1
0
        public async Task <IActionResult> PutFaqtb001Dialogo([FromRoute] int id, [FromBody] Faqtb001Dialogo faqtb001Dialogo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != faqtb001Dialogo.NuDialogo)
            {
                return(BadRequest());
            }

            _context.Entry(faqtb001Dialogo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Faqtb001DialogoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PostFaqtb004Sessao([FromBody] SessaoDTO sessao)
        {
            ListaConversaDTO lsResposta = new ListaConversaDTO();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Faqtb004Sessao faqtb004Sessao = new Faqtb004Sessao();

            faqtb004Sessao.DhSessao  = DateTime.Now;
            faqtb004Sessao.NoUsuario = sessao.noUsuario;
            faqtb004Sessao.NuDialogo = sessao.nuDialogo;

            Faqtb002Conversa inicio = _context.Faqtb002Conversa
                                      .Where(c => c.NuDialogo == sessao.nuDialogo &&
                                             c.IcTipoConversa == "I")
                                      .Include(c => c.Faqtb003RegraNuConversaAnteriorNavigation)
                                      .Include(c => c.IcTipoConversaNavigation)
                                      .FirstOrDefault();
            Faqtb002Conversa conversa = buscaProximaConversa(inicio, faqtb004Sessao);

            MotorConversa(lsResposta, faqtb004Sessao, inicio);
            _context.Faqtb004Sessao.Add(faqtb004Sessao);
            await _context.SaveChangesAsync();


            lsResposta.nuSessao = faqtb004Sessao.NuSessao;

            return(Ok(lsResposta));
        }