public DriverStatisticDTO MapToDriverStatisticDTO(StatisticSetEntity source, DriverStatisticDTO target = null) { if (source == null) { return(null); } if (target == null) { target = new DriverStatisticDTO(); } target.StatisticSetId = source.Id; target.DriverStatisticRows = source.DriverStatistic.Select(x => MapToDriverStatisticRowDTO(x)).ToArray(); return(target); }
public ImportedStatisticSetEntity MapToImportedStatisticSetEntity(DriverStatisticDTO source, ImportedStatisticSetEntity target = null) { if (source == null) { return(null); } if (target == null) { target = DefaultGet <ImportedStatisticSetEntity>(new object[] { source.StatisticSetId }); } MapCollection(source.DriverStatisticRows, target.DriverStatistic, MapToDriverStatisticRowEntity, x => x.Keys, removeFromCollection: true, removeFromDatabase: true, autoAddMissing: true); target.FirstDate = target.DriverStatistic.Min(x => x.FirstSessionDate); target.LastDate = target.DriverStatistic.Max(x => x.LastSessionDate); return(target); }