public ServiceResponse<RequestSuccessfulResponse> UpdateVehicle(UpdateVehicleRequest request) { if (!request.CanProcessRequest()) throw new InvalidOperationException(); this._vehicleRepository.UpdateVehicle(request.VehicleToUpdate); return new ServiceResponse<RequestSuccessfulResponse>(new RequestSuccessfulResponse() { }); }
public async Task <IActionResult> Put( [FromServices] IMediator mediator, [FromBody] UpdateVehicleRequest command, [FromRoute] int id) { command.Id = id; var result = await mediator.Send(command); return(Ok(result)); }
public async Task <IActionResult> UpdateVehicle(int vehicleId, [FromBody] UpdateVehicleRequest request) => await Result.Create(request, Errors.UnProcessableRequest) .Map(value => new UpdateVehicleCommand( vehicleId, request.TeamName, request.ModelName, request.ManufacturingDate, request.VehicleSubtype)) .Bind(command => Sender.Send(command)) .Match(Ok, BadRequest);
public async Task <bool> AtualizarVeiculo(int id, UpdateVehicleRequest request) { try { HttpResponseMessage _message = await _client.PutAsync($"api/v1/Vehicles/{id}", new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json")); return(_message.IsSuccessStatusCode); } catch (Exception ex) { throw; } }
public async Task <ApiResponse> Put(long id, [FromBody] UpdateVehicleRequest updateRequest) { if (!ModelState.IsValid) { throw new ApiProblemDetailsException(ModelState); } var vehicle = _mapper.Map <Vehicle>(updateRequest); vehicle.Id = id; if (await _vehicleManager.UpdateAsync(vehicle)) { return(new ApiResponse($"Record with Id: {id} sucessfully updated.", true)); } else { throw new ApiProblemDetailsException($"Record with Id: {id} does not exist.", Status404NotFound); } }
public async Task <IActionResult> UpdateVehicle([FromBody] UpdateVehicleRequest request) { var result = await _vehiclesService.UpdateVehicle(request); return(HandleResult(result)); }