コード例 #1
0
        public async Task <IActionResult> GetAllEvents()
        {
            var claims = Request.HttpContext.User;

            Log.Information("EventsController: HTTP GET events/");
            var result = await _eventServices.ListEventsAsync();

            var items = _mapper.Map <IEnumerable <Event>, IEnumerable <EventReadDto> >(result);

            foreach (var item in items)
            {
                String hrefUrl = $"{ Request.Scheme.ToString() }://{ Request.Host.ToString() }{ Request.Path.ToString() }/{ item.EventId.ToString() }/atendees";
                item.Links.Add(new LinkReadDto {
                    Href = hrefUrl, Ref = "atendees", Type = "GET"
                });
            }

            return(Ok(new { items }));
        }