public ScoringTableEntity MapToScoringTableEntity(ScoringTableDataDTO source, ScoringTableEntity target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = GetScoringTableEntity(source);
            }

            if (MapToRevision(source, target) == false)
            {
                return(target);
            }

            target.DropWeeks      = source.DropWeeks;
            target.Name           = source.Name;
            target.ScoringKind    = source.ScoringKind;
            target.AverageRaceNr  = source.AverageRaceNr;
            target.ScoringFactors = source.ScoringFactors;
            if (target.Scorings == null)
            {
                target.Scorings = new List <ScoringEntity>();
            }
            MapCollection(source.ScoringIds.Select(x => new ScoringInfoDTO()
            {
                ScoringId = x
            }), target.Scorings, GetScoringEntity, x => x.Keys, removeFromCollection: true);
            target.ResultsPerRaceCount = source.ResultsPerRaceCount;
            target.DropRacesOption     = source.DropRacesOption;

            return(target);
        }
        public ScoringTableEntity MapToScoringTableEntity(ScoringTableDataDTO source, ScoringTableEntity target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = GetScoringTableEntity(source);
            }

            if (MapToRevision(source, target) == false)
            {
                return(target);
            }

            target.DropWeeks      = source.DropWeeks;
            target.Name           = source.Name;
            target.ScoringFactors = source.ScoringFactors;
            if (target.Scorings == null)
            {
                target.Scorings = new List <ScoringEntity>();
            }
            MapCollection(source.Scorings, target.Scorings, GetScoringEntity, x => x.Keys, removeFromCollection: true);

            return(target);
        }
        public ScoringTableDataDTO MapToScoringTableDataDTO(ScoringTableEntity source, ScoringTableDataDTO target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = new ScoringTableDataDTO();
            }

            MapToScoringTableInfoDTO(source, target);

            target.AverageRaceNr       = source.AverageRaceNr;
            target.DropWeeks           = source.DropWeeks;
            target.ScoringFactors      = source.ScoringFactors;
            target.ScoringKind         = source.ScoringKind;
            target.ScoringIds          = source.Scorings.Select(x => x.ScoringId).ToArray();
            target.SeasonId            = source.SeasonId; // MapToSeasonInfoDTO(source.Season);
            target.SessionIds          = source.Sessions.Select(x => x.SessionId).ToArray();
            target.DropRacesOption     = source.DropRacesOption;
            target.ResultsPerRaceCount = source.ResultsPerRaceCount;

            return(target);
        }
        public ScoringTableDataDTO MapToScoringTableDataDTO(ScoringTableEntity source, ScoringTableDataDTO target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = new ScoringTableDataDTO();
            }

            MapToScoringTableInfoDTO(source, target);

            target.AverageRaceNr  = source.AverageRaceNr;
            target.DropWeeks      = source.DropWeeks;
            target.ScoringFactors = source.ScoringFactors;
            target.Scorings       = source.Scorings.Select(x => MapToScoringInfoDTO(x)).ToArray();
            target.Season         = MapToSeasonInfoDTO(source.Season);
            target.Sessions       = source.Sessions.Select(x => MapToSessionInfoDTO(x)).ToArray();

            return(target);
        }