internal async Task <TableResult> AddGifsercise(GifserciseEntity gifsercise) { _log.Info($"In gifRepo: new Entity: index: {gifsercise.RowKey}, image_url: {gifsercise.image_url}, text: {gifsercise.text}"); try { TableOperation insertOperation = TableOperation.Insert(gifsercise); var insertResult = await _table.ExecuteAsync(insertOperation); if (insertResult.HttpStatusCode < 300) { _log.Info($"insert successful with status: {insertResult.HttpStatusCode}"); } else { _log.Info($"insert failed with status: {insertResult.HttpStatusCode}, result: {insertResult.Result.ToString()}"); } return(insertResult); } catch (Exception ex) { _log.Error($"insert unsuccessful", ex); throw; } }
internal static async Task <HttpResponseMessage> PostToSlack(GifserciseEntity gifsercise) { var gifText = string.Concat(gifsercise.text, @" | <!channel>"); var slackMessage = new SlackMessage(gifsercise.image_url, gifText); var slackOutput = new StringContent(JsonConvert.SerializeObject(slackMessage), Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { return(await client.PostAsync((Environment.GetEnvironmentVariable("slack.webhook")), slackOutput)); } }