private void InitializeTasksDuration()
 {
     // Evaluate job duration and format it
     if (DeploymentJob.MaxTaskFinishTime.HasValue && DeploymentJob.MinTaskStartTime.HasValue)
     {
         TasksDuration = $"{TimeSpanFormatter.FormatDuration(DeploymentJob.MaxTaskFinishTime.Value.Subtract(DeploymentJob.MinTaskStartTime.Value), true)}";
     }
 }
        private void InitializeDuration(List <TaskData> tasks)
        {
            if (tasks.Count == 1)
            {
                var firstTask = tasks.First();
                if (firstTask.FinishTime.HasValue && firstTask.StartTime.HasValue)
                {
                    Duration = TimeSpanFormatter.FormatDuration(firstTask.FinishTime.Value.Subtract(firstTask.StartTime.Value),
                                                                true);
                }
            }
            else if (tasks.Any(t => t.FinishTime.HasValue && t.StartTime.HasValue))
            {
                var minTime = tasks.Where(t => t.FinishTime.HasValue && t.StartTime.HasValue).Min(t => t.FinishTime.Value.Subtract(t.StartTime.Value));
                var maxTime = tasks.Where(t => t.FinishTime.HasValue && t.StartTime.HasValue).Max(t => t.FinishTime.Value.Subtract(t.StartTime.Value));

                if (minTime != null && maxTime != null)
                {
                    Duration = $"{TimeSpanFormatter.FormatDuration(minTime, false)} - {TimeSpanFormatter.FormatDuration(maxTime, false)}";
                }
            }
        }