Esempio n. 1
0
        public static EditionDTO ToEditionDTO(Edition edition, string language)
        {
            var details    = edition.Details.FirstOrDefault(item => item.Language == language) ?? edition.Details.First();
            var activities = EditionActivityUtils.ToEditionActivitiesDTO(edition.Activities, language);

            var users    = edition.Activities.SelectMany(c => c.Users).GroupBy(c => c.User.Id).Select(c => c.First());
            var speakers = UserUtils.ToUsersDTO(users, language);

            return(new EditionDTO
            {
                Id = edition.Id,
                Language = language,
                Name = details.Name,
                Description = details.Description,
                Date = details.Date,
                LocationName = edition.LocationName,
                LocationFullAddress = edition.LocationFullAddress,
                Event = EventUtils.ToEventDTO(edition.Event, language),
                Organizers = UserUtils.ToUsersDTO(edition.Organizers?.Select(item => item.User).ToList(), language),
                EditionTickets = EditionUtils.ToEditionTicketsDTO(edition.EditionTickets),
                Sponsors = EditionUtils.ToEditionSponsorsDTO(edition.Sponsors),
                Activities = activities,
                Speakers = speakers
            });
        }
        public static EditionActivitiesDTO ToEditionActivitiesDTO(IEnumerable <EditionActivity> editionActivies, string language)
        {
            var editionActivitiesDTO = new EditionActivitiesDTO
            {
                Days = new List <EditionActivityDayDTO>()
            };

            if (editionActivies == null)
            {
                return(editionActivitiesDTO);
            }

            var activities = editionActivies
                             .Select(editionActivity => EditionActivityUtils.ToEditionActivityDTO(editionActivity, language))
                             .ToList();

            editionActivitiesDTO.Days = activities
                                        .GroupBy(c => c.Day).OrderBy(c => c.Key)
                                        .Select(c => new EditionActivityDayDTO()
            {
                Name   = c.Key,
                Tracks = c.GroupBy(item => item.Track).OrderBy(item => item.Key)
                         .Select(item => new EditionActivityTrackDTO
                {
                    Name       = item.Key,
                    Activities = item.OrderBy(activity => activity.Date).ToList()
                })
                         .ToList()
            })
                                        .ToList();

            return(editionActivitiesDTO);
        }