Пример #1
0
        public async Task <IActionResult> GetUsers(UserQueryParameters parameters, [FromHeader(Name = "Accept")] string mediaType)
        {
            _logger.LogInformation("Querying for users");
            var userDtos = await _userQuery.ExecuteGetResourcesAsync(parameters);

            _logger.LogInformation($"Shaping user resource based of off field(s): {parameters.Fields}");
            var expandoObjects = userDtos.ShapeData(parameters.Fields);

            if (mediaType == "application/vnd.marvin.hateoas+json")
            {
                var outerFacingModels = CreateUsersWithLinks(userDtos, expandoObjects, parameters);

                _logger.LogInformation($"returning users resource");

                return(Ok(outerFacingModels));
            }

            _logger.LogInformation($"returning users resource");

            return(Ok(expandoObjects));
        }