public static async Task Run([QueueTrigger(QueueNameConstants.TextModelForDatabase)] TextMoodModel textModel, ILogger log) { log.LogInformation("Saving TextModel to Database"); if (textModel.Text.Length > 128) { textModel.Text = textModel.Text.Substring(0, 128); } await TextMoodDatabase.InsertTextModel(textModel).ConfigureAwait(false); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequestMessage httpRequest, TraceWriter log) { log.Info("Retrieving Text Models from Database"); try { var textModelList = await TextMoodDatabase.GetAllTextModels().ConfigureAwait(false); return(httpRequest.CreateResponse(System.Net.HttpStatusCode.OK, textModelList)); } catch (System.Exception e) { return(httpRequest.CreateErrorResponse(System.Net.HttpStatusCode.InternalServerError, e)); } }
public static void Run( [QueueTrigger(QueueNameConstants.TextModelForDatabase)] TextMoodModel textModel, [Queue(QueueNameConstants.SendUpdate)] out TextMoodModel textModelOutput, TraceWriter log) { log.Info("Saving TextModel to Database"); if (textModel.Text.Length > 128) { textModel.Text = textModel.Text.Substring(0, 128); } TextMoodDatabase.InsertTextModel(textModel).GetAwaiter().GetResult(); textModelOutput = textModel; }
public static async Task <ActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest httpRequest, TraceWriter log) { log.Info("Retrieving Text Models from Database"); try { var textModelList = await TextMoodDatabase.GetAllTextModels().ConfigureAwait(false); log.Info($"Success"); return(new OkObjectResult(textModelList)); } catch (System.Exception e) { log.Info($"Failed: {e.Message}"); throw; } }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest httpRequest, ILogger log) { log.LogInformation("Retrieving Text Models from Database"); try { var textModelList = await TextMoodDatabase.GetAllTextModels().ConfigureAwait(false); log.LogInformation($"Success"); return(new OkObjectResult(textModelList)); } catch (System.Exception e) { log.LogError(e, e.Message); throw; } }
public GetTextModels(TextMoodDatabase textMoodDatabase) => _textMoodDatabase = textMoodDatabase;
public SaveTextModelToDatabase(TextMoodDatabase textMoodDatabase) => _textMoodDatabase = textMoodDatabase;