Пример #1
0
        public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "books")] HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // Populate sample book data:
            BuildData.Initialise();

            return(new OkObjectResult(Data.Books));
        }
Пример #2
0
        public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "books")] HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // Populate sample book data:
            BuildData.Initialise();

            string  requestBody = new StreamReader(req.Body).ReadToEnd();
            dynamic book        = JsonConvert.DeserializeObject(requestBody, typeof(Models.Book));

            Data.Books.Add(book);

            return(new OkResult());
        }
Пример #3
0
        public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "books/{id}")] HttpRequest req, string id, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // Populate sample book data:
            BuildData.Initialise();

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

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

            var book = Data.Books.Find(q => q.id == id);

            return(new OkObjectResult(book));
        }