public void Handle(ExcluirEventoCommand cmd) { Evento evento = _eventoRepository.ObterEventoCompletoPaginaPorId(cmd.Id); if (evento == null) { return; } List <Atracao> atracoes = new List <Atracao>(); evento.AtracoesEventos.ToList().ForEach(x => { atracoes.Add(x.Atracao); _eventoRepository.RemoverAtracaoEvento(x.AtracaoId, x.EventoId); }); foreach (var atracao in atracoes) { _eventoRepository.RemoverAtracao(atracao.Id); } _eventoRepository.RemoverEndereco(cmd.EnderecoId); _eventoRepository.Remover(cmd.Id); if (Commit()) { _mediator.PublicarEvento(new AtracaoExcluidaEvent(cmd.Id)); } }
static void Main(string[] args) { var bus = new FakeBus(); // Registro com sucesso var cmd = new RegistrarEventoCommand("DevX", DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), true, 0, true, "Empresa"); Inicio(cmd); bus.SendCommand(cmd); Fim(cmd); // Registro com erros cmd = new RegistrarEventoCommand("", DateTime.Now.AddDays(2), DateTime.Now.AddDays(1), false, 0, false, ""); Inicio(cmd); bus.SendCommand(cmd); Fim(cmd); // Atualizar Evento var cmd2 = new AtualizarEventoCommand(Guid.NewGuid(), "DevX", "", "", DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), false, 50, true, "Empresa"); Inicio(cmd2); bus.SendCommand(cmd2); Fim(cmd2); // Excluir Evento var cmd3 = new ExcluirEventoCommand(Guid.NewGuid()); Inicio(cmd3); bus.SendCommand(cmd3); Fim(cmd3); Console.ReadKey(); }
public IActionResult Delete(Guid id) { var eventoCommand = new ExcluirEventoCommand(id); _mediator.EnviarComando(new ExcluirEventoCommand(id)); return(Response()); }
public async Task <CommandResponse> Handle(ExcluirEventoCommand command, CancellationToken cancellationToken) { var qtdPessoas = new QuantidadePessoas(command.QtdPessoas); var email = new Email(command.Email); var evento = new Evento(command.Id, command.Local, Convert.ToDateTime(command.DataEvento), command.Tema, qtdPessoas, command.ImagemUrl, command.Telefone, email, command.Lotes, command.RedesSociais); _repository.Excluir(evento); if (await _repository.Commitar()) { Response.Success = true; Response.Messages.Add("Evento excluído com sucesso!"); return(Response); } Response.Success = false; Response.Messages.AddRange(evento.Notifications.Select(x => x.Message)); return(Response); }
public void Handle(ExcluirEventoCommand message) { if (!EventoExistente(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 negocio eventoAtual.ExcluirEvento(); _eventoRepository.Atualizar(eventoAtual); if (Commit()) { _bus.RaiseEvent(new EventoExcluidoEvent(message.Id)); } }
public void ExcluirEvento() { //var bus = new FakeBus(); //Criar o comando de registro com sucesso var cmd = new RegistrarEventoCommand( "Nome do Evento", "Descricao Evento", "Desc Event", DateTime.Now.AddDays(20), DateTime.Now.AddDays(20), true, 0, true, "Wagner Nogueira", Guid.Empty, Guid.Empty, null); //bus.SendCommand(cmd); var excluir = new ExcluirEventoCommand(cmd.Id); //bus.SendCommand(excluir); }
public void Handle(ExcluirEventoCommand message) { throw new NotImplementedException(); }