Example #1
0
        public IActionResult GetPerformances([FromQuery] PerformancesResourceParameters parameters)
        {
            if (!_propertyMappingService.ValidMappingExistsFor <PerformanceDto, Performance>(parameters.OrderBy) ||
                !_propertyCheckerService.TypeHasProperties <PerformanceDto>(parameters.Fields))
            {
                return(BadRequest());
            }

            if (!string.IsNullOrEmpty(parameters.Fields) && !parameters.Fields.Contains("id"))
            {
                return(BadRequest());
            }

            var performances = _unitOfWork.Performances.GetPerformances(parameters);

            Response.Headers.Add("X-Pagination",
                                 JsonConvert.SerializeObject(
                                     _paginationService.CreatePaginationMetadata(performances, parameters)));

            return(Ok(_dataShapingService.GetShapedCollectionWithLinks(performances, parameters)));
        }