public IEnumerable <Event> GetEventByStartDate(bool ascending)
        {
            try
            {
                IEnumerable <Event> @events = _eventRepository.GetSortedByStartDate(ascending);

                _logger.LogInfo($"Returned all Events from database.");

                List <Event> eventsList = new List <Event>();
                foreach (Event @event in @events.ToList())
                {
                    IEnumerable <EventGenreDto> eventGenres = _eventGenreLogic.GetByEventWithDetails(@event.id);
                    @event.genre = _mapper.Map <ICollection <EventGenre> >(eventGenres);
                    eventsList.Add(@event);
                }

                //IEnumerable<EventDto> eventDtos = _mapper.Map<IEnumerable<EventDto>>(eventsList);

                return(eventsList);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside GetAll action: {ex.Message}");
                throw new Exception();
            }
        }
示例#2
0
        public IActionResult GetByEventWithDetails(int event_id)
        {
            try
            {
                IEnumerable <EventGenreDto> genres = _eventGenreLogic.GetByEventWithDetails(event_id);

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

                return(Ok(genres));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error"));
            }
        }