public ScoringDataDTO MapToScoringDataDTO(ScoringEntity source, ScoringDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new ScoringDataDTO(); } MapToScoringInfoDTO(source, target); target.AverageRaceNr = source.AverageRaceNr; target.BasePoints = source.BasePoints; target.BonusPoints = source.BonusPoints; target.CreatedByUserId = source.CreatedByUserId; target.LastModifiedByUserId = source.LastModifiedByUserId; target.DropWeeks = source.DropWeeks; target.IncPenaltyPoints = source.IncPenaltyPoints; target.MultiScoringFactors = source.MultiScoringFactors; target.MultiScoringResults = source.MultiScoringResults.Select(x => MapToScoringInfoDTO(x)).ToArray(); target.IsMultiScoring = source.IsMultiScoring; target.Name = source.Name; target.Season = MapToSeasonInfoDTO(source.Season); //target.SeasonId = source.SeasonId; target.Sessions = ((source.IsMultiScoring) ? source.GetAllSessions() : source.Sessions).Select(x => MapToSessionInfoDTO(x)).ToArray(); target.Results = source.Results.Select(x => MapToResultInfoDTO(x)).ToArray(); target.ConnectedSchedule = MapToScheduleInfoDTO(source.ConnectedSchedule); return(target); }
public ScoringEntity MapToScoringEntity(ScoringDataDTO source, ScoringEntity target = null) { if (source == null) { return(null); } if (target == null) { GetScoringEntity(source); } if (!MapToRevision(source, target)) { return(target); } target.AverageRaceNr = source.AverageRaceNr; target.BasePoints = source.BasePoints; target.BonusPoints = source.BonusPoints; target.CreatedByUserId = source.CreatedByUserId; target.LastModifiedByUserId = source.LastModifiedByUserId; target.DropWeeks = source.DropWeeks; target.IncPenaltyPoints = source.IncPenaltyPoints; target.Name = source.Name; if (target.Season == null && source.SeasonId != 0) { //target.Season = GetSeasonEntity(new SeasonInfoDTO() { SeasonId = source.SeasonId }); target.Season = DefaultGet <SeasonEntity>(source.SeasonId); } if (target.Sessions == null) { target.Sessions = new List <Entities.Sessions.SessionBaseEntity>(); } else { MapCollection(source.SessionIds.Select(x => new SessionInfoDTO() { SessionId = x }), target.Sessions, GetSessionBaseEntity, x => x.SessionId); } //target.ConnectedSchedule = GetScheduleEntity(source.ConnectedScheduleId != null ? new ScheduleInfoDTO() { ScheduleId = source.ConnectedScheduleId } : null); target.ConnectedSchedule = DefaultGet <ScheduleEntity>(source.ConnectedScheduleId); if (target.ConnectedSchedule != null) { target.Sessions = target.ConnectedSchedule.Sessions; } target.ScoringKind = source.ScoringKind; target.MaxResultsPerGroup = source.MaxResultsPerGroup; target.TakeGroupAverage = source.TakeGroupAverage; //target.ExtScoringSource = GetScoringEntity(source.ExtScoringSourceId != null ? new ScoringInfoDTO() { ScoringId = source.ExtScoringSourceId } : null); target.ExtScoringSource = DefaultGet <ScoringEntity>(source.ExtScoringSourceId); target.TakeResultsFromExtSource = source.TakeResultsFromExtSource; target.GetAllSessions().Where(x => x.SessionResult != null).ForEach(x => x.SessionResult.RequiresRecalculation = true); target.UseResultSetTeam = source.UseResultSetTeam; target.UpdateTeamOnRecalculation = source.UpdateTeamOnRecalculation; return(target); }