public void Setup()
 {
     validVehicle         = new Domain.Entities.Vehicle(1, "honda", "Civic", "prata", "abc1234", 1);
     handlerError         = new VehicleCommandHandler(new ErrorVehicleRepository(), new CompanyVehicleCommandHandler(new ErrorCompanyVehicleRepository()), new ErrorCompanyVehicleRepository());
     handlerSuccess       = new VehicleCommandHandler(new SuccessVehicleRepository(), new CompanyVehicleCommandHandler(new SuccessCompanyVehicleRepository()), new SuccessCompanyVehicleRepository());
     removeVehicleCommand = new RemoveVehicleCommand(10);
 }
Пример #2
0
        public async Task <IActionResult> Delete([FromQuery] string chassis, [FromQuery] bool confirm)
        {
            var command = new RemoveVehicleCommand(chassis, confirm);
            var result  = await mediator.SendCommandAsync(command);

            return(await ResponseBase(result));
        }
Пример #3
0
        public async Task <ActionResult <int> > RemoveVehicle(int id, int vehicleId, RemoveVehicleCommand command)
        {
            if (id != command.EmployeeId || vehicleId != command.VehicleId)
            {
                return(BadRequest());
            }

            return(await Mediator.Send(command));
        }
        public async Task Handle(RemoveVehicleCommand command)
        {
            DomainModel.Vehicle vehicle = await _repository.GetAsync(command.Id);

            if (vehicle == null)
            {
                return;
            }
            await _repository.RemoveAsync(vehicle);
        }
Пример #5
0
        public async Task <IActionResult> Delete(
            [FromServices] IBus bus,
            string id)
        {
            var command = new RemoveVehicleCommand(id);

            await bus.Send(command);

            return(Ok());
        }
        public Task <bool> Handle(RemoveVehicleCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            _vehicleRepository.Remove(message.Id);

            if (Commit())
            {
                _bus.RaiseEvent(new VehicleRemovedEvent(message.Id));
            }

            return(Task.FromResult(true));
        }
        public async Task <bool> Handler(RemoveVehicleCommand command)
        {
            if (command.Id == 0)
            {
                AddNotification("", "Veículo inexistente");
                return(false);
            }
            await _companyVehicleRepository.DeleteByVehicleId(command.Id);

            var result = await _repository.Delete(command.Id);

            if (!result)
            {
                AddNotification("", "Erro ao remover o veículo");
                return(false);
            }
            return(true);
        }
Пример #8
0
        public void Remove(Guid id)
        {
            var removeCommand = new RemoveVehicleCommand(id);

            _bus.SendCommand(removeCommand);
        }