Exemplo n.º 1
0
        public async Task <IActionResult> InsertTarefaPostAsync([FromBody] TarefaFormViewModel modelo, string listaId)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var tarefa          = modelo.ToTarefaInsert();
                    var tarefaResultado = await _tarefaRepository.InsertTarefaAsync(tarefa, _userManager.GetUserId(User));

                    var tarefaHtml = await this.RenderViewToStringAsync("~/Areas/Painel/Views/Tarefa/partial/_Tarefa.cshtml", tarefaResultado);

                    return(Ok(new { tarefaHtml }));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
            }

            return(PartialView("partial/_NovaTarefa", modelo));
        }