public async Task <ResponseModel <string> > AddAsync(ChatModel chatModel) { if (await _chatRepository.CreateAsync(MapToChat.MapToChatEntity(chatModel))) { return(new GetResponse <string>("").GetSuccessResponse()); } return(new GetResponse <string>("").GetErrorResponse("Error when try to create.")); }
public async Task <string> GetChatNameAsync(string userName) { ChatWithNestedObjects chatWithNestedObjects = await _chatRepository.GetByNameAsync(userName); if (chatWithNestedObjects is null) { Chat chat = new Chat { Name = userName }; await _chatRepository.CreateAsync(chat); return(chat.Name); } return(chatWithNestedObjects.Chat.Name); }
public async Task ExecuteAsync(Message message, TelegramBotClient client) { var chatId = message.Chat.Id; var name = !string.IsNullOrEmpty(message.Chat.Title) ? message.Chat.Title : $"{message.Chat.FirstName} {message.Chat.LastName}"; var chat = new ChatDto { Id = chatId, Name = name }; await _repository.CreateAsync(chat); await client.SendTextMessageAsync(chatId, $"Chat registered with a name {name}"); }