Exemple #1
0
        public ResultsFilterOptionDTO MapToResultsFilterOptionDTO(ResultsFilterOptionEntity source, ResultsFilterOptionDTO target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = new ResultsFilterOptionDTO();
            }

            MapToVersionDTO(source, target);

            target.ColumnPropertyName = source.ColumnPropertyName;
            target.Comparator         = source.Comparator;

            switch (source.ColumnPropertyName)
            {
            case nameof(ResultRowEntity.MemberId):
                target.ColumnPropertyName = nameof(ResultRowDataDTO.MemberId);
                break;

            case nameof(ResultRowEntity.Member) + "." + nameof(LeagueMemberEntity.Team) + "." + nameof(TeamEntity.Name):
                target.ColumnPropertyName = nameof(ResultRowDataDTO.TeamName);
                break;

            default:
                target.ColumnPropertyName = source.ColumnPropertyName;
                break;
            }
            var targetColumnProperty = typeof(ResultRowDataDTO).GetNestedPropertyInfo(target.ColumnPropertyName);
            var sourceColumnProperty = typeof(ResultRowEntity).GetNestedPropertyInfo(source.ColumnPropertyName);

            target.FilterValues      = source.FilterValues.Split(';').Select(x => ConvertToResultsValueObject(sourceColumnProperty.PropertyType, x, targetColumnProperty.PropertyType)).ToArray();
            target.ResultsFilterId   = source.ResultsFilterId;
            target.ResultsFilterType = source.ResultsFilterType;
            target.Exclude           = source.Exclude;
            target.ScoringId         = source.ScoringId;
            target.FilterPointsOnly  = source.FilterPointsOnly;

            return(target);
        }
Exemple #2
0
        public ResultsFilterOptionEntity MapToResultsFilterOptionEntity(ResultsFilterOptionDTO source, ResultsFilterOptionEntity target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = DefaultGet <ResultsFilterOptionDTO, ResultsFilterOptionEntity>(source);
            }

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

            switch (source.ColumnPropertyName)
            {
            case nameof(ResultRowDataDTO.MemberId):
                target.ColumnPropertyName = nameof(ResultRowEntity.MemberId);
                break;

            case nameof(ResultRowDataDTO.TeamName):
                target.ColumnPropertyName = $"{nameof(ResultRowEntity.Member)}.{nameof(LeagueMemberEntity.Team)}.{nameof(TeamEntity.Name)}";
                break;

            default:
                target.ColumnPropertyName = source.ColumnPropertyName;
                break;
            }
            target.Comparator = source.Comparator;
            // get target and source columnproperty
            var targetColumnProperty = typeof(ResultRowEntity).GetNestedPropertyInfo(target.ColumnPropertyName);
            var sourceColumnProperty = typeof(ResultRowDataDTO).GetNestedPropertyInfo(source.ColumnPropertyName);

            target.FilterValues      = String.Join(";", source.FilterValues.Select(x => ConvertToResultsValueString(sourceColumnProperty.PropertyType, x, targetColumnProperty.PropertyType)));
            target.ResultsFilterType = source.ResultsFilterType;
            target.Exclude           = source.Exclude;
            if (target.Scoring == null && target.ScoringId == 0)
            {
                target.Scoring = DefaultGet <ScoringEntity>(new object[] { source.ScoringId });
            }
            target.Scoring?.GetAllSessions().Where(x => x.SessionResult != null).ForEach(x => x.SessionResult.RequiresRecalculation = true);
            target.FilterPointsOnly = source.FilterPointsOnly;

            return(target);
        }