public async Task <IActionResult> GetCenterById(Guid centerId, string fields, [FromHeader(Name = "Accept")] string mediaType) { if (!MediaTypeHeaderValue.TryParse(mediaType, out MediaTypeHeaderValue parsedMediaType)) { return(BadRequest()); } if (string.IsNullOrWhiteSpace(centerId.ToString())) { return(BadRequest(new { message = "Center Id should not be null or empty!" })); } if (!_propertyCheckerService.TypeHasProperties <CenterDto> (fields)) { return(BadRequest()); } var center = await _centerRepository.GetCenterByIdAsync(centerId); if (center == null) { return(NotFound()); } if (parsedMediaType.MediaType == "application/vnd.marvin.hateoas+json") { var links = CreateLinksForCenter(centerId, fields); var linkedResourceToReturn = _mapper.Map <CenterDto> (center).ShapeData(fields) as IDictionary <string, object>; linkedResourceToReturn.Add("links", links); return(Ok(linkedResourceToReturn)); } return(Ok(_mapper.Map <CenterDto> (center).ShapeData(fields))); }