public Task Handle(ExcluirEventoCommand message, CancellationToken cancellationToken)
        {
            if (!EventoExistente(message.Id, message.MessageType))
            {
                return(Task.CompletedTask);
            }

            var eventoAtual = _eventoRepository.ObterPorId(message.Id);

            // To Do: Validar se o evento pertence a pessoa que está excluindo. Usuário logado é diferente do usuário criador do evento, portanto não posso alterar
            // Com o GetUserId vc garante pegar o usuário que está de fato conectado no momento
            if (eventoAtual.OrganizadorId != _user.GetUserId())
            {
                _mediator.PublicarEvento(new DomainNotification(message.MessageType, "Evento não pertence ao Organizador"));
                return(Task.CompletedTask);
            }

            eventoAtual.ExcluirEvento();

            _eventoRepository.Atualizar(eventoAtual);

            if (Commit())
            {
                _mediator.PublicarEvento(new EventoExcluidoEvent(message.Id));
            }

            return(Task.CompletedTask);
        }
Пример #2
0
        public void Handle(ExcluirEventoCommand message)
        {
            if (!EventoExiste(message.Id, message.MessageType))
            {
                return;
            }

            var eventoAtual = _eventoRepository.ObterPorId(message.Id);

            if (eventoAtual.OrganizadorId != _user.GetUserId())
            {
                _bus.RaiseEvent(new DomainNotification(message.MessageType, "Evento não pertence ao Organizador!"));
                return;
            }

            // Validações de negócio
            eventoAtual.ExcluirEvento(); // Exclusão lógica

            _eventoRepository.Atualizar(eventoAtual);

            if (Commit())
            {
                _bus.RaiseEvent(new EventoExcluidoEvent(message.Id));
            }
        }
Пример #3
0
        public void Handle(ExcluirEventoCommand message)
        {
            // Verifica se há evento com o ID informado
            if (!EventoExistente(message.Id, message.MessageType))
            {
                return;
            }

            var eventoAtual = _eventoRepository.ObterPorId(message.Id);

            // Validações de negócio
            if (eventoAtual.OrganizadorId != _user.GetUserId()) // Não posso excluir um evento que não seja meu
            {
                _bus.RaiseEvent(new DomainNotification(message.MessageType, "Evento não pertence ao Organizador!"));
                return;
            }

            eventoAtual.ExcluirEvento();

            _eventoRepository.Atualizar(eventoAtual);

            if (Commit())
            {
                _bus.RaiseEvent(new EventoExcluidoEvent(message.Id));
            }
        }
        public Task <bool> Handle(ExcluirEventoCommand message, CancellationToken cancellationToken)
        {
            if (!EventoExiste(message.Id, message.MessageType))
            {
                return(Task.FromResult(false));
            }

            var eventoAtual = _eventoRepository.ObterPorId(message.Id);

            if (eventoAtual.OrganizadorId != _user.GetUserId())
            {
                _mediator.PublicarEvento(new DomainNotification(message.MessageType, "Evento não pertence ao Organizador!"));
                return(Task.FromResult(false));
            }

            // Validações de negócio
            eventoAtual.ExcluirEvento(); // Exclusão lógica

            _eventoRepository.Atualizar(eventoAtual);

            if (Commit())
            {
                _mediator.PublicarEvento(new EventoExcluidoEvent(message.Id));
            }

            return(Task.FromResult(true));
        }
        public Task Handle(ExcluirEventoCommand Message, CancellationToken cancellationToken)
        {
            if (!EventoExistente(Message.Id, Message.MessageType))
            {
                return(Task.FromResult(Unit.Value));
            }

            var eventoAtual = _eventoRepository.ObterPorId(Message.Id);

            if (eventoAtual.OrganizadorId != _user.GetUserId())
            {
                _mediator.PublicarEvento(new DomainNotification(Message.MessageType, "Evento não pertence ao Organizador"));
                return(Task.FromResult(Unit.Value));
            }

            eventoAtual.ExcluirEvento();

            _eventoRepository.Atualizar(eventoAtual);

            if (Commit())
            {
                _mediator.PublicarEvento(new EventoExcluidoEvent(Message.Id));
            }

            return(Task.FromResult(Unit.Value));
        }
Пример #6
0
        public void Handle(ExcluirEventoCommand message)
        {
            if (!EventoExistente(message.Id, message.MessageType))
            {
                return;
            }
            _eventoRepository.Remover(message.Id);

            if (Commit())
            {
                _bus.RaiseEvent(new EventoExcluidoEvent(message.Id));
            }
        }
Пример #7
0
        public void Handle(ExcluirEventoCommand message)
        {
            if (!EventoExistente(message.Id, message.MessageType))
            {
                return;
            }

            _eventoRepository.Remover(message.Id);

            if (Commit())
            {
                Console.Write("Evento excluído com sucesso");
                _bus.RaiseEvent(new EventoExcluidoEvent(message.Id));
            }
        }
Пример #8
0
        public void Handle(ExcluirEventoCommand message)
        {
            if (!EventoExistente(message.Id, message.MessageType))
            {
                return;
            }

            var eventoAtual = _eventoRepository.ObterPorId(message.Id);

            //Validações de Negócio
            eventoAtual.ExcluirEvento();

            _eventoRepository.Atualizar(eventoAtual);

            if (Commit())
            {
                _bus.RaiseEvent(new EventoExcluidoEvent(message.Id));
            }
        }
Пример #9
0
 public void Handle(ExcluirEventoCommand message)
 {
     throw new NotImplementedException();
 }