private void SaveContextActivity(Message message) { var context = new BotContext { Chat = message.Chat, LastCommand = message.Text }; var currentContext = BotStorage.GetBotContextByChatId(message.Chat.Id); if (currentContext == null) { BotStorage.SaveOrUpdateContext(context); } else { currentContext.Context = context; BotStorage.SaveOrUpdateContext(currentContext); } }
public void SaveOrUpdateContext(BotContext context) { _botContexts.AddOrUpdate(context.Chat.Id, context, (key, val) => context); }