public Response GetHelpRequestsSummary(APIGatewayProxyRequest request, ILambdaContext context) { var getRequestGateway = new INeedHelpGateway(new Cv19SupportDbContext(_connectionString)); var getRequestObject = new GetHelpRequestsUseCase(getRequestGateway); try { var resp = getRequestObject.GetHelpRequestsSummary(); LambdaLogger.Log(("Records retrieval success: " + resp.ToString())); var response = new Response(); response.isBase64Encoded = true; response.statusCode = "200"; response.body = JsonConvert.SerializeObject(resp); return(response); } catch (Exception e) { LambdaLogger.Log("Error: " + e.Message); var response = new Response(); response.isBase64Encoded = true; response.statusCode = "500"; response.body = "Error processing request: " + ". Error Details: " + e.Message + e.StackTrace; return(response); } }
public Response GetHelpRequests(APIGatewayProxyRequest request, ILambdaContext context) { var getRequestGateway = new INeedHelpGateway(new Cv19SupportDbContext(_connectionString)); var getRequestObject = new GetHelpRequestsUseCase(getRequestGateway); var requestParams = request.QueryStringParameters; bool master = false; string uprn = null; string postcode = null; try { master = bool.Parse(requestParams["master"]); LambdaLogger.Log("master: " + master); } catch (Exception e) { LambdaLogger.Log("master parameter not provided."); } try { uprn = requestParams["uprn"]; LambdaLogger.Log("uprn: " + uprn); } catch (Exception e) { LambdaLogger.Log("uprn parameter not provided."); } try { postcode = requestParams["postcode"]; LambdaLogger.Log("postcode: " + postcode); } catch (Exception e) { LambdaLogger.Log("postcode parameter not provided."); } try { var resp = getRequestObject.GetHelpRequests(uprn, postcode, master) .Select(x => x.ToResponse()); LambdaLogger.Log("Records retrieval success: " + JsonConvert.SerializeObject(resp)); var response = new Response(); response.isBase64Encoded = true; response.statusCode = "200"; response.body = JsonConvert.SerializeObject(resp); return(response); } catch (Exception e) { LambdaLogger.Log("Error: " + e.Message); var response = new Response(); response.isBase64Encoded = true; response.statusCode = "500"; response.body = "Error processing request: " + ". Error Details: " + e.Message + e.StackTrace; return(response); } }