generated from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Created UpdateParticipant function (#3)
* feat: Created UpdateParticipant function * refactor: Moved Participant class to separate file
- Loading branch information
1 parent
43be19e
commit 4112479
Showing
8 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,8 @@ | |
!project.code-workspace | ||
|
||
# Please, add your custom content below! | ||
|
||
|
||
# Builds | ||
bin | ||
obj |
4 changes: 4 additions & 0 deletions
4
src/ParticipantManagementService/UpdateParticipant/Participant.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
public class Participant | ||
{ | ||
public string NhsNumber { get; set; } | ||
} |
11 changes: 11 additions & 0 deletions
11
src/ParticipantManagementService/UpdateParticipant/Program.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
var host = new HostBuilder() | ||
.ConfigureFunctionsWorkerDefaults() | ||
.ConfigureServices(services => | ||
{ | ||
|
||
}) | ||
.Build(); | ||
host.Run(); |
9 changes: 9 additions & 0 deletions
9
src/ParticipantManagementService/UpdateParticipant/Properties/launchSettings.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"profiles": { | ||
"updateParticipant": { | ||
"commandName": "Project", | ||
"commandLineArgs": "--port 7253", | ||
"launchBrowser": false | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/ParticipantManagementService/UpdateParticipant/UpdateParticipant.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace updateParticipant; | ||
|
||
using System.Net; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
using Microsoft.Extensions.Logging; | ||
using System.Text; | ||
using System.Text.Json; | ||
|
||
|
||
public class UpdateParticipant | ||
{ | ||
private readonly ILogger<UpdateParticipant> _logger; | ||
|
||
public UpdateParticipant(ILogger<UpdateParticipant> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[Function("updateParticipant")] | ||
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req) | ||
{ | ||
Participant participant; | ||
try | ||
{ | ||
using (StreamReader reader = new StreamReader(req.Body, Encoding.UTF8)) | ||
{ | ||
var postData = reader.ReadToEnd(); | ||
participant = JsonSerializer.Deserialize<Participant>(postData); | ||
} | ||
|
||
_logger.LogInformation(participant.NhsNumber); | ||
|
||
return req.CreateResponse(HttpStatusCode.OK); | ||
|
||
} | ||
catch | ||
{ | ||
_logger.LogError("Could not read participant"); | ||
|
||
return req.CreateResponse(HttpStatusCode.BadRequest); | ||
} | ||
} | ||
} | ||
|
||
|
26 changes: 26 additions & 0 deletions
26
src/ParticipantManagementService/UpdateParticipant/UpdateParticipant.csproj
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" /> | ||
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="host.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="local.settings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
<CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" /> | ||
</ItemGroup> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
src/ParticipantManagementService/UpdateParticipant/host.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
}, | ||
"enableLiveMetricsFilters": true | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/ParticipantManagementService/UpdateParticipant/local.settings.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" | ||
}, | ||
"Host": { | ||
"LocalHttpPort": 6000 | ||
} | ||
} |