Example #1
0
    public async Task SaveAuth(AuthorizedChat authorizedChat)
    {
        var authCollection = GetAuthCollection();
        var lists          = await authCollection.Query().ToListAsync();

        if (lists.Any(chat => chat.ChatId == authorizedChat.ChatId))
        {
            await authCollection.DeleteManyAsync(chat => chat.ChatId == authorizedChat.ChatId);

            await authCollection.InsertAsync(authorizedChat);
        }

        await authCollection.InsertAsync(authorizedChat);
    }
Example #2
0
    public async Task UnAuth(AuthorizedChat authorizedChat = null)
    {
        var authCollection = GetAuthCollection();

        if (authorizedChat == null)
        {
            Log.Debug("Unauthorizing all chat..");
            await authCollection.DeleteAllAsync();
        }
        else
        {
            Log.Debug("Unauthorizing {ChatId}", authorizedChat.ChatId);
            await authCollection.DeleteManyAsync(chat => chat.ChatId == authorizedChat.ChatId);
        }

        Log.Debug("Unauthorizing finish..");
    }