예제 #1
0
        //[Produces("application/json", "application/problem+json")]
        public async Task <IActionResult> GetConcert(Guid id, int?expanded = null)
        {
            object concert;
            object result;

            if (!expanded.HasValue || expanded == 0)
            {
                concert = await _concertsRepository.GetConcertAsync(id);

                if (concert == null)
                {
                    return(NotFound());
                }
                result = Mapper.Map <ConcertDto>(concert);
            }
            else
            {
                concert = await _concertsRepository.GetConcertExpandedAsync(id);

                if (concert == null)
                {
                    return(NotFound());
                }
                //Fake mapper
                result = Transformer.Transform <ConcertDto>(concert);
            }
            return(Ok(result));
        }
예제 #2
0
        public async Task <IActionResult> GetConcert(Guid id)
        {
            var concert = await _concertsRepository.GetConcertAsync(id);

            if (concert == null)
            {
                return(NotFound());
            }
            var result = Mapper.Map <ConcertDto>(concert);

            var response = new HALResponse(result)
                           .AddLinks(new Link("self", $"/core/v1/concerts"))
                           .AddLinks(new Link("concert:users", $"/core/v1/concerts/{id}/users"));

            return(Ok(response));
        }