/// <summary> /// Extract event entity into event Dto /// </summary> /// <param name="entity"></param> /// <returns></returns> public static EventDto Extract(Event entity) { var dto = new EventDto(); if (entity == null) { return(dto); } dto.Id = entity.Id; dto.Name = entity.Name; dto.Date = entity.Date; dto.IsPublished = entity.IsPublished; dto.Description = entity.Description; dto.Resume = entity.Resume; dto.NumberMaxOfParticipant = entity.NbMaxOfParticipant; dto.RendezVousPoint = entity.RendezVousPoint; if (entity.Participants != null) { dto.NumberOfParticipant = entity.Participants.Count; } if (entity.Creator != null) { dto.CreatorName = entity.Creator.UserName; } // Get participants if (entity.Participants != null && entity.Participants.Any()) { dto.Participants = entity.Participants.Select(pr => UserDto.Extract(pr.User)).ToList(); } // Get hosts if (entity.Hosts != null && entity.Hosts.Any()) { dto.Hosts = entity.Hosts.Select(hs => UserDto.Extract(hs.User)).ToList(); } //dto.Seance = SeanceDto.Extract(entity.Seances); if (entity.Seances != null && entity.Seances.Any()) { dto.Seance = entity.Seances.Select(sc => SeanceDto.Extract(sc.Seance)).ToList(); } return(dto); }