Example #1
0
        public IActionResult Get(int id)
        {
            var timesheet = _timesheetService.Get(id).ToApiModel();

            if (timesheet == null)
            {
                return(NotFound());
            }
            return(Ok(timesheet));
        }
Example #2
0
        /// <summary>
        /// A Lambda function to respond to HTTP methods from API Gateway
        /// </summary>
        /// <param name="request"></param>
        /// <returns>The API Gateway response.</returns>
        public async Task <APIGatewayProxyResponse> Handler(APIGatewayProxyRequest request, ILambdaContext context)
        {
            timesheetService.Logger = context.Logger;
            var userId = request.PathParameters["UserId"];
            var weekId = request.PathParameters["Id"];

            string response = null;

            switch (request.HttpMethod.ToUpper())
            {
            case "GET":
                response = await timesheetService.Get(userId, weekId);

                break;

            case "POST":
                await timesheetService.Post(userId, weekId, request.Body);

                response = string.Empty;
                break;

            default:
                break;
            }

            if (response == null)
            {
                return(new APIGatewayProxyResponse
                {
                    StatusCode = (int)HttpStatusCode.NotFound
                });
            }

            return(new APIGatewayProxyResponse
            {
                StatusCode = (int)HttpStatusCode.OK,
                Body = response,
                Headers = new Dictionary <string, string> {
                    { "Content-Type", "text/json" }
                }
            });
        }
        public TimesheetModel Get(Guid userId, int maand)
        {
            var jaar = DateTime.Now.Year;

            return(_service.Get(userId, maand, jaar));
        }