public async Task <APIGatewayProxyResponse> HandleRequestAsync(APIGatewayProxyRequest request, ILambdaContext context) { context.Logger.LogLine($"APIGateway request: {JsonConvert.SerializeObject(request)}"); string vin = WebUtility.UrlDecode(request.PathParameters["id"]); IValidateVIN validateVIN = _sp.GetRequiredService <IValidateVIN>(); if (!validateVIN.IsValid(vin)) { return(APIGatewayProxyResponses.BadRequest()); } IVehicleDataService dataService = _sp.GetRequiredService <IVehicleDataService>(); VehicleData data = await dataService.GetVehicleDataAsync(vin); if (data == null) { return(APIGatewayProxyResponses.NotFound(vin)); } var body = new ResponseBody { VIN = data.VIN, CustomerId = data.CustomerId, Make = data.Make, Model = data.Model, ModelYear = data.ModelYear, ImportedDate = data.ImportedDate }; return(APIGatewayProxyResponses.OKContent(body)); }
public async Task <APIGatewayProxyResponse> HandleRequestAsync(APIGatewayProxyRequest request, ILambdaContext context) { context.Logger.LogLine($"APIGateway request: {JsonConvert.SerializeObject(request)}"); ImportRequest requestBody = JsonConvert.DeserializeObject <ImportRequest>(request.Body); IValidateVIN validateVIN = _sp.GetRequiredService <IValidateVIN>(); if (!validateVIN.IsValid(requestBody.VIN)) { return(APIGatewayProxyResponses.BadRequest()); } IVehicleDataService dataService = _sp.GetRequiredService <IVehicleDataService>(); await dataService.ImportVehicleDataAsync(requestBody.CustomerId, requestBody.VIN); return(APIGatewayProxyResponses.OK()); }