コード例 #1
0
        public IActionResult Excluir(int id)
        {
            var tarefa = _tarefaRepository.ObterPorId(id);

            _tarefaRepository.Excluir(id);
            return(RedirectToAction("Todas", "Tarefa", new { id = tarefa.ProjetoId }));
        }
コード例 #2
0
        public async Task <ActionResult <TarefaViewModel> > ObterPorId(Guid id)
        {
            var tarefaViewModel = _mapper.Map <TarefaViewModel>(await _tarefaRepository.ObterPorId(id));

            if (tarefaViewModel == null)
            {
                return(NotFound());
            }

            return(tarefaViewModel);
        }
コード例 #3
0
        public Task Handle(ExcluirTarefaCommand message, CancellationToken cancellationToken)
        {
            if (!TarefaExistente(message.Id, message.MessageType))
            {
                return(Task.FromCanceled(cancellationToken));
            }
            var tarefaAtual = _tarefaRepository.ObterPorId(message.Id);

            // Validacoes de negocio
            tarefaAtual.ExcluirTarefa();

            _tarefaRepository.Remover(tarefaAtual.Id);

            if (Commit())
            {
                _mediator.PublicarTarefa(new TarefaExcluidoEvent(message.Id));
            }
            return(Task.CompletedTask);
        }
コード例 #4
0
        public override async Task Atualizar(Tarefa tarefa)
        {
            if (!ExecutarValidacao(AbstractValidator, tarefa))
            {
                return;
            }

            var tarefaAtualizacao = await _tarefaRepository.ObterPorId(tarefa.Id);

            tarefaAtualizacao.Titulo              = tarefa.Titulo;
            tarefaAtualizacao.Descricao           = tarefa.Descricao;
            tarefaAtualizacao.EquipeId            = tarefa.EquipeId;
            tarefaAtualizacao.Estado              = tarefa.Estado;
            tarefaAtualizacao.DataUltimaAlteracao = DateTime.UtcNow.Date;

            await _tarefaRepository.Atualizar(tarefaAtualizacao);
        }
コード例 #5
0
 public Tarefa ObterPorId(int id) => _tarefaRepository.ObterPorId(id);
コード例 #6
0
 private async Task <Tarefa> ObterPorId(Guid id) =>
 await tarefaRepository.ObterPorId(id);
コード例 #7
0
 public TarefaViewModel Get(long id)
 {
     return(_mapper.Map <TarefaViewModel>(_tarefaRepository.ObterPorId(id)));
 }