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 void Atualizar(EventoViewModel eventoViewModel) { //TODO: Validar se o organizador é dono do evento AtualizarEventoCommand atualizarEventoCommand = _mapper.Map <AtualizarEventoCommand>(eventoViewModel); _bus.SendCommand(atualizarEventoCommand); }
public IActionResult Put([FromBody] AtualizarEventoCommand eventoCommand) { // Atualiza o evento // Caso estive usando a camada Application //_eventoRepository.Atualizar(eventoCommand); _bus.SendCommand(eventoCommand); return(Response(eventoCommand)); }
public void AtualizarEvento() { //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 att = new AtualizarEventoCommand(cmd.Id, "Legal", "Descricao", "Desc", DateTime.Now.AddDays(12), DateTime.Now.AddDays(13), true, 0, true, "Wagner Nogueira", Guid.Empty, Guid.Empty); //bus.SendCommand(att); }
public void Handle(AtualizarEventoCommand message) { var eventoAtual = _eventoRepository.ObterPorId(message.Id); if (!EventoExistente(message.Id, message.MessageType)) { return; } //Jeito 1 //if(eventoAtual.OrganizadorId != message.OrganizadorId) //{ // _bus.RaiseEvent(new DomainNotification(message.MessageType, "Evento não pertence ao organizador!")); // return; //} //Jeito 2 if (eventoAtual.OrganizadorId != _user.GetUserId()) { _bus.RaiseEvent(new DomainNotification(message.MessageType, "Evento não pertence ao organizador!")); return; } var evento = Evento.EventoFactory.NovoEventoCompleto(message.Id, message.Nome, message.DescricaoCurta, message.DescricaoLonga, message.DataInicio, message.DataFim, message.Gratuito, message.Valor, message.Online, message.NomeEmpresa, message.OrganizadorId, eventoAtual.Endereco, message.CategoriaId); if (!evento.Online && evento.Endereco == null) { _bus.RaiseEvent(new DomainNotification(message.MessageType, "Não é possivel atualizar o evento sem informar um enderereço")); return; } if (!EventoValido(evento)) { return; } _eventoRepository.Atualizar(evento); if (Commit()) { _bus.RaiseEvent(new EventoAtualizadoEvent(evento.Id, evento.Nome, evento.DescricaoCurta, evento.DescricaoLonga, evento.DataInicio, evento.DataFim, evento.Gratuito, evento.Valor, evento.Online, evento.NomeEmpresa)); } }
public void Handle(AtualizarEventoCommand cmd) { var evento = EventoExistente(cmd.Id, cmd.MessageType); if (evento == null) { return; } evento.AtualizarEvento(cmd.Nome, cmd.Descricao, cmd.SubDescricao, cmd.DescPatrocinadores, cmd.DataHoraInicio, cmd.DataHoraFim, cmd.Situacao, cmd.CategoriaId); if (!evento.IsValid()) { NotificarValidacoesErro(evento.ValidationResult); return; } _eventoRepository.Atualizar(evento); if (Commit()) { _mediator.PublicarEvento(new EventoAtualizadoEvent(cmd.Id, cmd.Nome, cmd.Descricao, cmd.SubDescricao, cmd.DescPatrocinadores, cmd.DataHoraInicio, cmd.DataHoraFim, cmd.Situacao)); } }
public void Handle(AtualizarEventoCommand message) { throw new NotImplementedException(); }
public IActionResult Put([FromForm] AtualizarEventoCommand eventoCommand) { _bus.SendCommand(eventoCommand); return(Response(eventoCommand)); }
public async Task <ActionResult> PutEvento(Guid codigo, Guid codigoEvento, AtualizarEventoCommand command) { command.CodigoProcessoJuridico = codigo; command.CodigoEvento = codigoEvento; return(RespostaCasoDeUso(await _mediator.Send(command))); }