public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); jwt = data.JWT; JWT jwtHelper = new JWT(); game = jwtHelper.GetGameFromJWT(jwt); Question questionHelper = new Question() { SqlConnectionString = Environment.GetEnvironmentVariable("SQL_CONNECTION_STRING") }; question = await questionHelper.CreateQuestionAsync(game); await SendMessageAsync(); var returnObject = new { Question = question }; return((ActionResult) new OkObjectResult(JsonConvert.SerializeObject(returnObject))); //: new BadRequestObjectResult("Please pass a name on the query string or in the request body"); }
public async Task <IActionResult> Post([FromBody] GameSession gameSession) { JWT jwtHelper = new JWT(); game = jwtHelper.GetGameFromJWT(gameSession.JWT); SqlConnectionString sqlConnectionString = new SqlConnectionString(); Question questionHelper = new Question() { SqlConnectionString = sqlConnectionString.GetSqlConnectionString() }; question = await questionHelper.CreateQuestionAsync(game); await _hubContext.Clients.All.SendAsync($"Game{game}", "NewQuestion"); var returnObject = new { Question = question }; return((ActionResult) new OkObjectResult(JsonConvert.SerializeObject(returnObject))); }
public async Task <IActionResult> Post([FromBody] GameSession gameSession) { JWT jwtHelper = new JWT(); SqlConnectionString sqlConnectionString = new SqlConnectionString(); Question questionHelper = new Question() { SqlConnectionString = sqlConnectionString.GetSqlConnectionString() }; game = jwtHelper.GetGameFromJWT(gameSession.JWT); question = await questionHelper.GetQuestionFromGameAsync(game); await questionHelper.MakeQuestionAnswerableAsync(question); await _hubContext.Clients.All.SendAsync($"Game{game}", "Answerable"); var returnObject = new { Status = "Question is now Answerable" }; return((ActionResult) new OkObjectResult(JsonConvert.SerializeObject(returnObject))); }