public SeasonDataDTO MapToSeasonDataDTO(SeasonEntity source, SeasonDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new SeasonDataDTO(); } MapToSeasonInfoDTO(source, target); target.CreatedByUserId = source.CreatedByUserId; target.LastModifiedByUserId = source.LastModifiedByUserId; target.Finished = source.Finished; target.Results = source.Results?.Select(x => MapToResultInfoDTO(x)).ToArray(); target.Reviews = source.Results?.Select(x => x.Reviews?.Select(y => MapToReviewInfoDTO(y))).Aggregate((x, y) => x.Concat(y)).ToArray(); target.Schedules = source.Schedules?.Select(x => MapToScheduleInfoDTO(x)).ToArray(); target.Scorings = source.Scorings?.Select(x => MapToScoringDataDTO(x)).ToArray(); target.ScoringTables = source.ScoringTables?.Select(x => MapToScoringTableDataDTO(x)).ToArray(); target.SeasonEnd = source.SeasonEnd.GetValueOrDefault(); target.SeasonId = source.SeasonId; target.SeasonName = source.SeasonName; target.SeasonStart = source.SeasonStart.GetValueOrDefault(); target.Version = source.Version; target.VoteCategories = LeagueDbContext.CustomVoteCategories.AsEnumerable().Select(x => MapToVoteCategoryDTO(x)).ToArray(); target.CustomIncidents = LeagueDbContext.CustomIncidentKinds.AsEnumerable().Select(x => MapToCustomIncidentDTO(x)).ToArray(); target.HideCommentsBeforeVoted = source.HideCommentsBeforeVoted; target.SeasonStatisticSetIds = source.SeasonStatistics.Select(x => x.Id).ToArray(); return(target); }
public SeasonDataDTO MapToSeasonDataDTO(SeasonEntity source, SeasonDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new SeasonDataDTO(); } MapToSeasonInfoDTO(source, target); target.CreatedByUserId = source.CreatedByUserId; target.LastModifiedByUserId = source.LastModifiedByUserId; target.Results = source.Results?.Select(x => MapToResultInfoDTO(x)).ToList(); target.Reviews = source.Results?.Select(x => x.Reviews?.Select(y => MapToReviewInfoDTO(y))).Aggregate((x, y) => x.Concat(y)); target.Schedules = source.Schedules?.Select(x => MapToScheduleInfoDTO(x)).ToList(); target.Scorings = source.Scorings?.Select(x => MapToScoringDataDTO(x)).ToList(); target.ScoringTables = source.ScoringTables?.Select(x => MapToScoringTableDataDTO(x)).ToList(); target.SeasonEnd = source.SeasonEnd.GetValueOrDefault(); target.SeasonId = source.SeasonId; target.SeasonName = source.SeasonName; target.SeasonStart = source.SeasonStart.GetValueOrDefault(); target.Version = source.Version; return(target); }
public SeasonEntity MapToSeasonEntity(SeasonDataDTO source, SeasonEntity target = null) { if (source == null) { return(null); } if (target == null) { GetSeasonEntity(source); } if (!MapToRevision(source, target)) { return(target); } target.SeasonName = source.SeasonName; target.Finished = source.Finished; target.CreatedByUserId = source.CreatedByUserId; target.LastModifiedByUserId = source.LastModifiedByUserId; if (target.Schedules == null) { target.Schedules = new List <Entities.Sessions.ScheduleEntity>(); } MapCollection(source.Schedules, target.Schedules, GetScheduleEntity, x => x.MappingId, autoAddMissing: true); if (target.Scorings == null) { target.Scorings = new List <Entities.Results.ScoringEntity>(); } MapCollection(source.Scorings, target.Scorings, MapToScoringEntity, x => x.ScoringId, autoAddMissing: true); if (target.ScoringTables == null) { target.ScoringTables = new List <Entities.Results.ScoringTableEntity>(); } MapCollection(source.ScoringTables, target.ScoringTables, MapToScoringTableEntity, x => x.ScoringTableId, autoAddMissing: true); target.SeasonName = source.SeasonName; target.Version = source.Version; target.HideCommentsBeforeVoted = source.HideCommentsBeforeVoted; return(target); }