Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }