public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); int moveNumber = int.Parse(req.Query["MoveNumber"]); var sDSWumpusData = new SDSWumpusData(); string maxRepeatedItem; try { var wumpusActionVotes = await sDSWumpusData.AggregateWumpusDataValue(moveNumber); maxRepeatedItem = wumpusActionVotes.GroupBy(x => x.WumpusAction) .OrderByDescending(x => x.Count()) .First().Key; } catch (Exception ex) { log.LogError("There was an error in getting aggregrate value", ex); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } return(new OkObjectResult(new Result { voteResult = maxRepeatedItem })); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var data = JsonConvert.DeserializeObject <WumpusActionVote>(requestBody); data.TimeStamp = DateTime.Now; var sDSWumpusData = new SDSWumpusData(); // await sDSWumpusData.GetOrCreateWumpusType(); // await sDSWumpusData.GetOrCreateWumpusStream(); try { await sDSWumpusData.InsertWumpusValue(data); } catch (Exception ex) { log.LogError("There was an error in inserting the value", ex); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } return(new OkObjectResult(true)); }