private async Task BuildInsertCommandHandlerSuccess()
        {
            InsertVehicleCommand saveVehicle = (InsertVehicleCommand)validVehicle;
            int result = await handlerSuccess.Handler(saveVehicle);

            SuccessTests(handlerSuccess.Invalid, result > 0, handlerSuccess.Notifications);
        }
        private async Task BuildInsertCommandHandlerError()
        {
            InsertVehicleCommand saveVehicle = (InsertVehicleCommand)validVehicle;
            int result = await handlerError.Handler(saveVehicle);

            ErrorTests(handlerError.Invalid, result > 0, handlerError.Notifications);
        }
Example #3
0
 public Vehicle(InsertVehicleCommand insertVehicle)
 {
     Brand = insertVehicle.Brand;
     Model = insertVehicle.Model;
     Color = insertVehicle.Color;
     Plate = insertVehicle.Plate;
     Type  = insertVehicle.Type;
 }
        public Task <IActionResult> Post([FromRoute] int id, [FromBody] Vehicle vehicle, [FromServices] VehicleCommandHandler vehicleHandler)
        {
            InsertVehicleCommand vehicleCommand = vehicle;

            vehicleCommand.CreateVehicleCompany(id);
            var result = vehicleHandler.Handler(vehicleCommand);

            return(Response(result, vehicleHandler.Notifications));
        }
        public async Task <int> Handler(InsertVehicleCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(0);
            }
            Vehicle vehicle = command;
            var     id      = await _repository.Insert(vehicle);

            if (id <= 0)
            {
                AddNotification("", "Erro ao persistir o veĆ­culo");
                return(0);
            }
            if (command.CreateLinkVehicle)
            {
                await SaveCompanyVehicle(id, command.CompanyId);
            }
            return(id);
        }
        public Task <IActionResult> Post([FromBody] InsertVehicleCommand vehicleCommand)
        {
            var result = _handler.Handler(vehicleCommand);

            return(Response(result, _handler.Notifications));
        }