public static string PerformancePoints(PerformanceDto performance)
        {
            if (performance == null || performance.Points == null)
            {
                return("");
            }
            var points = performance.Points.Value;

            return(points.ToString() + "p");
        }
        public static string PerformanceDepth(PerformanceDto performance)
        {
            if (performance == null || performance.Depth == null)
            {
                return("");
            }
            var depth = performance.Depth.Value;

            return(depth.ToString() + "m");
        }
        public static string PerformanceDistance(PerformanceDto performance)
        {
            if (performance == null || performance.Distance == null)
            {
                return("");
            }
            var distance = performance.Distance.Value;

            return(distance.ToString() + "m");
        }
        public static string PerformanceDuration(PerformanceDto performance)
        {
            if (performance == null || performance.Duration == null)
            {
                return("");
            }
            var duration = performance.Duration.Value;

            return(string.Format("{0}:{1:00}", duration.Minutes, duration.Seconds));
        }
        /// <summary>
        /// The assets are ordered by AssetName, then by year descending.
        /// </summary>
        private void CalculateAssertsPerformance()
        {
            var allAssets = _allAssetsFromService;
            var length    = allAssets.Length;

            var dtoList = new PerformanceDto[length];

            for (var i = 0; i < length; i++)
            {
                var curItem  = allAssets[i];
                var nextItem = i < length - 1 ? allAssets[i + 1] : null;

                dtoList[i] = CreatePerformanceDto(curItem, nextItem);
            }

            AllAssets = new ObservableCollection <PerformanceDto>(dtoList);
        }
 public static string Performance(PerformanceComponent component, PerformanceDto performance)
 {
     if (component == PerformanceComponent.Duration)
     {
         return(PerformanceDuration(performance));
     }
     if (component == PerformanceComponent.Distance)
     {
         return(PerformanceDistance(performance));
     }
     if (component == PerformanceComponent.Depth)
     {
         return(PerformanceDepth(performance));
     }
     if (component == PerformanceComponent.Points)
     {
         return(PerformancePoints(performance));
     }
     return("");
 }
        public static string PerformanceCombined(PerformanceDto performance)
        {
            StringBuilder sb         = new StringBuilder();
            var           formatters = new Func <PerformanceDto, string>[] { PerformanceDuration, PerformanceDistance, PerformanceDepth };

            foreach (var formatter in formatters)
            {
                var formatted = formatter(performance);
                if (string.IsNullOrEmpty(formatted))
                {
                    continue;
                }
                if (sb.Length != 0)
                {
                    sb.Append(", ");
                }
                sb.Append(formatted);
            }
            return(sb.ToString());
        }
Exemple #8
0
 public double PostGlobalRulesPoints(string rulesName, PerformanceDto performance)
 {
     return(apiRules.GetPoints(rulesName, performance));
 }
 public static Performance ConvertFromDto(this PerformanceDto performanceDto)
 {
     return(new Performance(performanceDto.Id, performanceDto.Description, TimeSpan.FromTicks(performanceDto.Duration)));
 }