Last active
January 9, 2021 04:06
-
-
Save KevinMcDonnell-BC/641e93d284183f468558c7170a1112e4 to your computer and use it in GitHub Desktop.
BCServerlessDemo DataAndFunctions API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // from https://github.com/BallardChalmers/BCServerlessDemo.DataAndFunctions/blob/master/BCServerless.DataAndFunctions.Functions/Api/JourneysApi.cs | |
| public async Task<HttpResponseMessage> Post(HttpRequestMessage req, TraceWriter log) | |
| { | |
| var payload = await req.Content.ReadAsAsync<Journey>(); | |
| var item = await _JourneyService.CreateAsync(payload, req); | |
| return req.CreateResponse(HttpStatusCode.Created, item); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // from https://github.com/BallardChalmers/BCServerlessDemo.DataAndFunctions/blob/master/BCServerless.DataAndFunctions.Functions/Api/JourneysApi.cs | |
| public async Task<HttpResponseMessage> Get(HttpRequestMessage req, TraceWriter log) | |
| { | |
| string idString = req.GetQueryNameValuePairs().Where(w => w.Key == "id").FirstOrDefault().Value; | |
| if (string.IsNullOrWhiteSpace(idString)) | |
| { | |
| var results = await _searchApi.Search<Journey, Journey>(req, log); | |
| return req.CreateResponse(HttpStatusCode.OK, results); | |
| } | |
| var Journey = await _JourneyService.Get(idString); | |
| if (Journey == null) | |
| { | |
| return req.CreateResponse(HttpStatusCode.NotFound); | |
| } | |
| return req.CreateResponse(HttpStatusCode.OK, Journey); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment