Exemplo n.º 1
0
        public async Task <IHttpActionResult> LoadChannels()
        {
            try
            {
                var client   = new SlackTaskClient(_configuration.AppSettings.Token);
                var response = await client.GetConversationListAsync();


                if (!response.ok)
                {
                    //TODO: properly manage response and display error messages
                    return(new SlackErrorResult(response.error, Request));
                }

                var mappedModels = response.channels.Select(c => new SlackEntity
                {
                    Id   = c.Id,
                    Name = c.Name
                });

                return(Ok(mappedModels));
            }
            catch (Exception ex)
            {
                Logger.Error(typeof(ConfigurationApiController), ex);
                return(InternalServerError(ex));
            }
        }