public ScoredTeamResultRowDataDTO MapToScoredTeamResultRowDataDTO(ScoredTeamResultRowEntity source, ScoredTeamResultRowDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new ScoredTeamResultRowDataDTO(); } //MapToResultRowDataDTO(source.ResultRow, target); target.ScoredResultRowId = source.ScoredResultRowId; target.BonusPoints = source.BonusPoints; target.FinalPosition = source.FinalPosition; target.FinalPositionChange = source.FinalPositionChange; target.PenaltyPoints = source.PenaltyPoints; target.RacePoints = source.RacePoints; target.ScoringId = source.ScoringId; target.TeamId = source.TeamId; target.FastestLapTime = TimeSpanConverter.Convert(source.FastestLapTime); target.AvgLapTime = TimeSpanConverter.Convert(source.AvgLapTime); target.ScoredResultRows = source.ScoredResultRows.Select(x => MapToScoredResultRowDataDTO(x)).ToArray(); target.TotalPoints = source.TotalPoints; return(target); }
private string ConvertToResultsValueString(Type sourceType, object source, Type targetType) { if (source == null) { return(null); } if (sourceType == null) { throw new ArgumentException("Error converting results value to string - sourceType was null"); } if (targetType == null) { throw new ArgumentException("Error converting results value to string - targetType was null"); } // convert values object target; if (sourceType.Equals(typeof(TimeSpan)) && targetType.Equals(typeof(long))) { target = TimeSpanConverter.Convert((TimeSpan)source); } else if (sourceType.Equals(typeof(LeagueMemberInfoDTO)) && targetType.Equals(typeof(long))) { target = ((LeagueMemberInfoDTO)source).MemberId; } else { target = Convert.ChangeType(source, targetType); } return(Convert.ToString(target)); }
public ResultRowDataDTO MapToResultRowDataDTO(ResultRowEntity source, ResultRowDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new ResultRowDataDTO(); } target.AvgLapTime = TimeSpanConverter.Convert(source.AvgLapTime); target.Car = source.Car; target.CarClass = source.CarClass; target.CarNumber = source.CarNumber; target.ClassId = source.ClassId; target.CompletedLaps = source.CompletedLaps; target.FastestLapTime = TimeSpanConverter.Convert(source.FastestLapTime); target.FastLapNr = source.FastLapNr; target.FinishPosition = source.FinishPosition; target.Incidents = source.Incidents; target.Interval = TimeSpanConverter.Convert(source.Interval); target.LeadLaps = source.LeadLaps; target.Member = MapToMemberInfoDTO(source.Member); target.PositionChange = source.PositionChange; target.QualifyingTime = TimeSpanConverter.Convert(source.QualifyingTime); target.ResultRowId = source.ResultRowId; target.ResultId = source.ResultId; target.StartPosition = source.StartPosition; target.Status = source.Status; return(target); }
private object ConvertToResultsValueObject(Type sourceType, string source, Type targetType) { if (source == null) { return(null); } if (sourceType == null) { throw new ArgumentException("Error converting results value string to object - sourceType was null"); } if (targetType == null) { throw new ArgumentException("Error converting results value string to object - targetType was null"); } // convert values if (string.IsNullOrEmpty(source)) { if (targetType.IsValueType) { return(Activator.CreateInstance(targetType)); } else { return(null); } } object sourceObject = Convert.ChangeType(source, sourceType); object target; if (sourceType.Equals(typeof(long)) && targetType.Equals(typeof(TimeSpan))) { target = TimeSpanConverter.Convert((long)sourceObject); } else if (sourceType.Equals(typeof(long)) && targetType.Equals(typeof(LeagueMemberInfoDTO))) { target = new LeagueMemberInfoDTO() { MemberId = (long)sourceObject }; } else if (sourceType.Equals(targetType)) { target = sourceObject; } else { target = Convert.ChangeType(sourceObject, targetType); } return(target); }
public ResultRowEntity MapToResultRowEntity(ResultRowDataDTO source, ResultRowEntity target = null) { if (source == null) { return(null); } if (target == null) { target = GetResultRowEntity(source); } target.AvgLapTime = TimeSpanConverter.Convert(source.AvgLapTime); target.Car = source.Car; target.CarClass = source.CarClass; target.CarNumber = source.CarNumber; target.ClassId = source.ClassId; target.CompletedLaps = source.CompletedLaps; target.FastestLapTime = TimeSpanConverter.Convert(source.FastestLapTime); target.FastLapNr = source.FastLapNr; target.FinishPosition = source.FinishPosition; target.Incidents = source.Incidents; target.Interval = TimeSpanConverter.Convert(source.Interval); target.LeadLaps = source.LeadLaps; target.Member = GetMemberEntity(new LeagueMemberInfoDTO() { MemberId = source.MemberId }); target.Team = DefaultGet <TeamEntity>(source.TeamId); target.PositionChange = source.PositionChange; target.QualifyingTime = TimeSpanConverter.Convert(source.QualifyingTime); target.StartPosition = source.StartPosition; target.Status = source.Status; target.Result = GetResultEntity(new ResultInfoDTO() { ResultId = source.ResultId }); target.OldIRating = source.OldIRating; target.NewIRating = source.NewIRating; target.CompletedPct = source.CompletedPct; target.OldSafetyRating = source.OldSafetyRating; target.NewSafetyRating = source.NewSafetyRating; target.OldLicenseLevel = source.OldLicenseLevel; target.NewLicenseLevel = source.NewLicenseLevel; target.OldCpi = source.OldCpi; target.NewCpi = source.NewCpi; return(target); }
public ResultRowDataDTO MapToResultRowDataDTO(ResultRowEntity source, ResultRowDataDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new ResultRowDataDTO(); } target.AvgLapTime = TimeSpanConverter.Convert(source.AvgLapTime); target.Car = source.Car; target.CarClass = source.CarClass; target.CarNumber = source.CarNumber; target.ClassId = source.ClassId; target.CompletedLaps = source.CompletedLaps; target.FastestLapTime = TimeSpanConverter.Convert(source.FastestLapTime); target.FastLapNr = source.FastLapNr; target.FinishPosition = source.FinishPosition; target.Incidents = source.Incidents; target.Interval = TimeSpanConverter.Convert(source.Interval); target.LeadLaps = source.LeadLaps; target.MemberId = source.MemberId; // MapToMemberInfoDTO(source.Member); target.PositionChange = source.PositionChange; target.QualifyingTime = TimeSpanConverter.Convert(source.QualifyingTime); target.ResultRowId = source.ResultRowId; target.ResultId = source.ResultId; target.StartPosition = source.StartPosition; target.Status = source.Status; target.TeamId = source.Team?.TeamId; target.TeamName = source.Team?.Name; target.LocationId = source.Result.Session.LocationId; target.Date = source.Date.GetValueOrDefault(); target.OldIRating = source.OldIRating; target.NewIRating = source.NewIRating; target.SeasonStartIRating = source.SeasonStartIRating; target.CompletedPct = source.CompletedPct; target.OldSafetyRating = source.OldSafetyRating; target.NewSafetyRating = source.NewSafetyRating; target.OldCpi = source.OldCpi; target.NewCpi = source.NewCpi; target.OldLicenseLevel = source.OldLicenseLevel; target.NewLicenseLevel = source.NewLicenseLevel; return(target); }
public StatisticSetDTO MapToStatisticSetDTO(StatisticSetEntity source, StatisticSetDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new StatisticSetDTO(); } MapToVersionDTO(source, target); target.Id = source.Id; target.Name = source.Name; target.UpdateInterval = TimeSpanConverter.Convert(source.UpdateInterval); target.UpdateTime = source.UpdateTime.GetValueOrDefault(); return(target); }
public StatisticSetEntity MapToStatisticSetEntity(StatisticSetDTO source, StatisticSetEntity target = null, bool force = false) { if (source == null) { return(null); } if (target == null) { throw new ArgumentNullException(nameof(target)); } if (MapToRevision(source, target) == false && force == false) { return(target); } target.Name = source.Name; target.UpdateInterval = TimeSpanConverter.Convert(source.UpdateInterval); target.UpdateTime = source.UpdateTime; target.RequiresRecalculation = true; return(target); }