示例#1
0
        protected override async Task <LambdaProxyResponse> ExecutionFunction(ApiGatewayProxyRequest request)
        {
            if (!request.PathParameters.ContainsKey("id"))
            {
                return(new LambdaProxyResponse
                {
                    statusCode = HttpStatusCode.BadRequest,
                    body = "No coffee ID defined in path parameter.",
                });
            }

            var id        = request.PathParameters["id"];
            var dbContext = new CoffeeContext(_context);

            return(!await dbContext.RemoveCoffee(id)
        ? new LambdaProxyResponse
            {
                statusCode = HttpStatusCode.InternalServerError,
                body = "There was a problem processing the request.",
            }

        : new LambdaProxyResponse
            {
                statusCode = HttpStatusCode.OK,
            });
        }