From 809a1feac70b08a271a2a1852bbda280c108d4cc Mon Sep 17 00:00:00 2001 From: Dmitrii Prokudin Date: Thu, 26 Dec 2024 04:48:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B1=D0=B5=D0=B4=D0=B8=D0=B2=D1=88?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/BotService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Services/BotService.cs b/Services/BotService.cs index 6f7935c..62bf0d6 100644 --- a/Services/BotService.cs +++ b/Services/BotService.cs @@ -93,10 +93,10 @@ public class BotService var selectedUser = await SelectUserOfTheDayAsync(chatId, today, type); - if (selectedUser.HasValue) + if (selectedUser.userId is not null) { var responseMessage = type == UserOfTheDayType.UserOfTheDay ? "Пользователь дня" : "Неудачник дня"; - await _botClient.SendTextMessageAsync(chatId, $"{responseMessage}: {selectedUser.Value}", cancellationToken: cancellationToken); + await _botClient.SendTextMessageAsync(chatId, $"{responseMessage}: {selectedUser.userName}", cancellationToken: cancellationToken); } else { @@ -110,7 +110,7 @@ public class BotService } } - private async Task SelectUserOfTheDayAsync(long chatId, DateTime date, UserOfTheDayType type) + private async Task<(long? userId, string userName)> SelectUserOfTheDayAsync(long chatId, DateTime date, UserOfTheDayType type) { var users = (await _userRepository.GetUsersWithNamesAsync(chatId)).ToList(); @@ -126,7 +126,7 @@ public class BotService if (!await _userOfTheDayRepository.IsUserAlreadySelectedAsync(chatId, date, selectedUser.userId)) { await _userOfTheDayRepository.RecordUserOfTheDayAsync(chatId, selectedUser.userId, date, type); - return selectedUser.userId; + return (selectedUser.userId, selectedUser.userName); } users.RemoveAt(randomIndex); @@ -134,7 +134,7 @@ public class BotService } } - return null; + return default; } private async Task HandleStatCommandAsync(Message message, CancellationToken cancellationToken)