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); }
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.ScoringId = source.ScoringId.GetValueOrDefault(); 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; //MapCollection(source.MultiScoringResults, target.MultiScoringResults, GetScoringEntity, x => x.ScoringId); target.Name = source.Name; target.Season = GetSeasonEntity(source.Season); target.IsMultiScoring = source.IsMultiScoring || target.MultiScoringResults?.Count > 0; if (target.Sessions == null) { target.Sessions = new List <Entities.Sessions.SessionBaseEntity>(); } if (target.IsMultiScoring == true || (target.MultiScoringResults != null && target.MultiScoringResults?.Count() > 0)) { target.Sessions.Clear(); } else { MapCollection(source.Sessions, target.Sessions, GetSessionBaseEntity, x => x.SessionId); } target.ConnectedSchedule = GetScheduleEntity(source.ConnectedSchedule); if (target.ConnectedSchedule != null) { target.Sessions = target.ConnectedSchedule.Sessions; } return(target); }
public ScoringInfoDTO MapToScoringInfoDTO(ScoringEntity source, ScoringInfoDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new ScoringInfoDTO(); } MapToVersionInfoDTO(source, target); target.ScoringId = source.ScoringId; return(target); }
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.Name = source.Name; target.SeasonId = source.SeasonId; // MapToSeasonInfoDTO(source.Season); target.SessionIds = source.Sessions.Select(x => x.SessionId).ToArray(); target.ResultIds = source.Results.Where(x => x != null).Select(x => x.ResultId).ToArray(); target.ConnectedScheduleId = source.ConnectedScheduleId; // MapToScheduleInfoDTO(source.ConnectedSchedule); target.ScoringKind = source.ScoringKind; target.MaxResultsPerGroup = source.MaxResultsPerGroup; target.TakeGroupAverage = source.TakeGroupAverage; target.ExtScoringSourceId = source.ExtScoringSourceId; // MapToScoringInfoDTO(source.ExtScoringSource); target.TakeResultsFromExtSource = source.TakeResultsFromExtSource; //target.ResultsFilterOptions = source.ResultsFilterOptions.Select(x => MapToResultsFilterOptionDTO(x)).ToArray(); target.ResultsFilterOptionIds = source.ResultsFilterOptions.Select(x => x.ResultsFilterId).ToArray(); target.UseResultSetTeam = source.UseResultSetTeam; target.UpdateTeamOnRecalculation = source.UpdateTeamOnRecalculation; return(target); }