private string GetExpenseStatisticText(long userId, DateTime?startDate = null, DateTime?endDate = null) { var statisticManager = new StatisticsManager(); List <ExpenseStatistic> expenseStatistics; decimal totalAmount; string period; if (startDate == null || endDate == null) { expenseStatistics = statisticManager.GetExpensesStatistic(userId); totalAmount = statisticManager.GetTotalAmountOfExpenses(userId); period = "весь час"; } else { expenseStatistics = statisticManager.GetExpensesStatistic(userId, startDate.Value, endDate.Value); totalAmount = statisticManager.GetTotalAmountOfExpenses(userId, startDate.Value, endDate.Value); period = startDate.Value.Year < DateTime.Now.Year ? startDate.Value.ToString("MMMM", culture) + " " + startDate.Value.Year : startDate.Value.ToString("MMMM", culture); } var downChart = new Emoji(0x1F4C9); StringBuilder answer = new StringBuilder($"{downChart} Статистика витрат по категоріям за <b>{period}</b>:\n"); foreach (var row in expenseStatistics) { var categoryEmoji = dbContext.GetCategoryEmoji(row.Category, CategoryType.Expense); answer.Append($"\t\t\t{categoryEmoji} {row.Category} - {row.TotalAmount} ₴ ({row.Percent}%)\n"); } answer.Append($"Загальна сума витрат: <u><b>{totalAmount} ₴</b></u>"); return(answer.ToString()); }