예제 #1
0
        public async static Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            string ratingid = req.Query["ratingid"];

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

            var dbRepo = new DocumentDBRepository <Rating>();

            // iRating rating = new iRating();

            //var rating = await dbRepo.GetItemAsync(ratingid);

            var result = await dbRepo.GetItemsAsync(d => d.id == ratingid);



            return(ratingid != null
                ? (ActionResult) new OkObjectResult(result.FirstOrDefault())
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body"));
        }