private async Task PopulateDayOfWeek() { var(durations, percentages) = await _statisticDatabase.GetStatisticByDayOfWeek(TimePeriod.All); var dayOfWeekOrder = "Window:Statistic:DayOfWeek:Order".TranslateAsIntList(); var dayOfWeekNames = "Window:Statistic:DayOfWeek:Name".TranslateAsList(); for (var i = 0; i < dayOfWeekOrder.Count; i++) { var dayOfWeekNumber = dayOfWeekOrder[i]; var dayOfWeek = (DayOfWeek)dayOfWeekNumber; var duration = TimeSpan.FromMilliseconds(durations[dayOfWeek]); var percent = percentages[dayOfWeek]; var item = new DayOfWeekItemModel { DayOfWeek = dayOfWeekNames[dayOfWeekNumber], Duration = duration.HumanizeForStatistic(Extensions.LanguageCodeConfigKey.Translate()), Percent = new PercentModel { Value = percent, ValueString = percent.ToString("Formats:Percentage".Translate()) } }; if (DayOfWeekData.Count <= i) { DayOfWeekData.Add(item); } else { DayOfWeekData[i] = item; } } }
private async Task PopulateDayOfWeek() { var(durations, percentages) = await _statisticDatabase.GetStatisticByDayOfWeek(TimePeriod.All); var dayOfWeekOrder = _config.GetList <int>($"{LocalizationService.SectionKey}:Window:Statistic:DayOfWeek:Order"); var dayOfWeekNames = _config.GetList <string>($"{LocalizationService.SectionKey}:Window:Statistic:DayOfWeek:Name"); for (var i = 1; i < dayOfWeekOrder.Count; i++) { var dayOfWeekNumber = dayOfWeekOrder[i]; var dayOfWeek = (DayOfWeek)dayOfWeekNumber; var duration = TimeSpan.FromMilliseconds(durations[dayOfWeek]); var percent = percentages[dayOfWeek]; var item = new DayOfWeekItemModel { DayOfWeek = dayOfWeekNames[dayOfWeekNumber], Duration = duration.HumanizeForStatistic(Localization[Extensions.LanguageCodeConfigKey]), Percent = new PercentModel { Value = percent, ValueString = percent.ToString(Localization["Formats:Percentage"]) } }; if (DayOfWeekData.Count <= i) { DayOfWeekData.Add(item); } else { DayOfWeekData[i] = item; } } }