public async Task <IActionResult> Post(TarefaModel Tarefa)
        {
            var result = await _tarefaService.AddAsync(Tarefa);

            await _unitOfWork.CommitAsync();

            return(Ok(result));
        }
Exemple #2
0
        public async Task <ActionResult <Tarefa> > PostTarefa(Tarefa tarefa)
        {
            tarefa.StatusTarefa = StatusTarefa.Ativa;
            tarefa.DataCriacao  = DateTime.Now;
            await _tarefaService.AddAsync(tarefa);

            await _tarefaService.SaveChangesAsync();

            return(CreatedAtAction("GetTarefa", new { id = tarefa.Id }, tarefa));
        }
Exemple #3
0
        public async Task <IActionResult> AddTarefa([Bind(nameof(TarefaViewModel.Nome), nameof(TarefaViewModel.Completa))] TarefaViewModel novaTarefa)
        {
            if (await TryUpdateModelAsync <TarefaViewModel>(novaTarefa, "tarefa", s => s.Nome, s => s.Completa))
            {
                await servico.AddAsync(novaTarefa);

                return(RedirectToAction(nameof(Tarefa)));
            }
            else
            {
                var errorList = (from item in ModelState
                                 where item.Value.Errors.Any()
                                 select item.Value.Errors[0].ErrorMessage).ToList();
                return(View());
            }
        }