Esempio n. 1
0
        public async Task SetRichMenuAsync(string userId, string menuName)
        {
            var menu = (await _client.GetRichMenuListAsync()).FirstOrDefault(m => m.Name == menuName);

            if (menu == null)
            {
                return;
            }

            var currentMenuId = "";

            try
            {
                currentMenuId = await _client.GetRichMenuIdOfUserAsync(userId);
            }
            catch (LineResponseException e)
            {
                if (e.StatusCode != System.Net.HttpStatusCode.NotFound)
                {
                    throw;
                }
            }

            if (menu.RichMenuId == currentMenuId)
            {
                return;
            }
            await _client.LinkRichMenuToUserAsync(userId, menu.RichMenuId);
        }