Exemplo n.º 1
0
        public StatsSummaryReadModel GetStatsSummary()
        {
            var    runs        = GetRuns();
            var    stats       = new StatsSummaryReadModel();
            double totalMeters = 0;

            foreach (var run in runs)
            {
                stats.TotalCalories += run.TotalCalories;
                stats.TotalDuration += run.Duration;
                totalMeters         += run.TotalDistance;
            }

            stats.TotalCaloriesFormatted   = $"{stats.TotalCalories:n0}";
            stats.TotalKilometers          = DistanceConverter.MetersToKilometers(totalMeters);
            stats.TotalKilometersFormatted = $"{stats.TotalKilometers:n0} km";
            stats.TotalMiles             = DistanceConverter.MetersToMiles(totalMeters);
            stats.TotalMilesFormatted    = $"{stats.TotalMiles:n0} mi";
            stats.TotalDurationFormatted = TimeFormatter.FormatToDhm(stats.TotalDuration);

            return(stats);
        }