コード例 #1
0
        //メンバーの名前を更新
        public async Task UpdateMember()
        {
            var lineMessagingClient = new LineMessagingClient(Environment.GetEnvironmentVariable("CHANNEL_ACCESS_TOKEN"));
            var iterator            = container.GetItemQueryIterator <Member>("SELECT * FROM c WHERE c.leavedDate = null");

            do
            {
                var result = await iterator.ReadNextAsync();

                foreach (var item in result)
                {
                    var user      = lineMessagingClient.GetGroupMemberProfileAsync(GroupId, item.id);
                    var NewerName = user.Result.DisplayName;

                    if (NewerName != item.newername)
                    {
                        var m = new Member
                        {
                            id         = item.id,
                            name       = item.name,
                            newername  = NewerName,
                            joinedDate = item.joinedDate,
                            check      = item.check,
                            postScript = item.postScript,
                            leavedDate = item.leavedDate
                        };
                        await container.UpsertItemAsync(m);
                    }
                }
            } while (iterator.HasMoreResults);
        }