forked from nickward13/ServerlessOpenHack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetRating.cs
40 lines (38 loc) · 1.24 KB
/
GetRating.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace Team1
{
public static class GetRating
{
[FunctionName("GetRating")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
[CosmosDB(
databaseName: "ratingsdata",
collectionName: "ratings",
ConnectionStringSetting = "CosmosDBConnection",
Id = "{Query.id}",
PartitionKey = "{Query.userId}")] RatingClass rating,
ILogger log)
{
log.LogInformation("GetRating HTTP trigger function processed a request");
if (rating == null)
{
log.LogInformation($"Rating item not found");
return new BadRequestResult();
}
else
{
log.LogInformation($"Found Rating item, Description={rating.id}");
return new OkObjectResult(rating);
}
}
}
}