Пример #1
0
        public static async Task <IActionResult> som([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "som/firstpost/")] HttpRequest req, ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            SomModel model = JsonConvert.DeserializeObject <SomModel>(requestBody);

            int result = model.Getal1 + model.Getal2;

            SomResultaat som = new SomResultaat();

            som.Resultaat = result;

            return(new OkObjectResult(som));



            //    log.LogInformation("C# HTTP trigger function processed a request.");

            //    string name = req.Query["name"];

            //    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            //    dynamic data = JsonConvert.DeserializeObject(requestBody);
            //    name = name ?? data?.name;

            //    return name != null
            //        ? (ActionResult)new OkObjectResult($"Hello, {name}")
            //        : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
        }
Пример #2
0
        public static async Task <IActionResult> Sum([HttpTrigger(AuthorizationLevel.Function, "post", Route = "Sum")] HttpRequest req, ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            SomModel data = JsonConvert.DeserializeObject <SomModel>(requestBody);

            int          som    = data.nr1 + data.nr2;
            SomResultaat result = new SomResultaat();

            result.resurltaat = som;
            return(new OkObjectResult(result));
        }