Пример #1
0
        public async Task <IActionResult> GetOneHallAsync(
            [FromRoute, SwaggerParameter(Description = "the ID to find hall by", Required = true)] Guid hallId,
            [FromHeader(Name = "Accept"), SwaggerParameter(Description = "media type to request between json or json+hateoas")] string mediaType)
        {
            var foundHall = await _hallRepository.GetHallAsync(hallId);

            if (foundHall == null)
            {
                return(NotFound());
            }

            var hallToReturn = Mapper.Map <HallDto>(foundHall);

            if (mediaType == "application/vnd.biob.json+hateoas")
            {
                var links = CreateLinksForHall(hallId);

                var linkedHall = hallToReturn.ShapeData(null) as IDictionary <string, object>;

                linkedHall.Add("links", links);

                return(Ok(linkedHall));
            }

            return(Ok(hallToReturn));
        }