Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet submission data persistence #69

Merged
merged 25 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8873fe0
Structure for persisting submission attempts
ashleybot Jul 24, 2024
65d93a1
In-progress updates for persisting submission logs
ashleybot Jul 24, 2024
7e9134b
Add methods and endpoints for managing submissions
ashleybot Jul 26, 2024
2600ef9
Add packet submission to dbcontext
ashleybot Jul 26, 2024
cbd697b
Add parent id properties
ashleybot Jul 26, 2024
074b7ef
Remove duplication
ashleybot Jul 26, 2024
5b863bf
Merge branch 'main' into packet-submission
ashleybot Aug 14, 2024
e33f95f
Fix route to packet submissions
ashleybot Aug 26, 2024
97930a8
Implements functionality for packet submissions and errors
ashleybot Aug 27, 2024
7084774
Add get visit with packet submissions paginated
ashleybot Aug 29, 2024
c47bbec
Add ability to gather all forms for packet submission
ashleybot Sep 4, 2024
4072564
Adjust to a collection of forms in packet submission
ashleybot Sep 4, 2024
f63f3f0
Upgrade to .NET 8
ashleybot Oct 14, 2024
746981f
In-progress
ashleybot Oct 16, 2024
2f6a32b
In-progress
ashleybot Oct 23, 2024
a48b69a
In-progress
ashleybot Oct 23, 2024
16f5beb
Cleanup and regenerate migration
ashleybot Oct 24, 2024
f5f28d9
Bump package build to .NET 8
ashleybot Oct 24, 2024
8363e86
Get visits and packets by status
ashleybot Oct 24, 2024
a0eba43
Fix query string
ashleybot Oct 24, 2024
b4be22e
Fix statuses in query
ashleybot Oct 24, 2024
ed6d33f
Ignore .github dir with linter
ashleybot Oct 25, 2024
2458963
Exclude gitignore directory from linting
ashleybot Oct 28, 2024
c27e878
Format exclude statement to known formatting
ashleybot Oct 28, 2024
02b42cf
Regenerate migration so assigned and resolved can be null. Ensure unr…
ashleybot Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"**/UDS.Net.API/Data/**"
],
"absolute": true
}
}
2 changes: 1 addition & 1 deletion .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
source-url: https://nuget.pkg.github.com/UK-SBCoA/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: "main"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_MARKDOWN: false
VALIDATE_MARKDOWN: false
FILTER_REGEX_EXCLUDE: (.*.github/.*|.*Properties/.*)
11 changes: 8 additions & 3 deletions src/UDS.Net.API.Client/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Net.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;

namespace UDS.Net.API.Client
{
Expand Down Expand Up @@ -29,6 +27,11 @@ public static void AddUDSApiClient(this IServiceCollection services, string base
options.BaseAddress = new Uri(baseAddress);
});

services.AddHttpClient<IPacketClient, PacketClient>(options =>
{
options.BaseAddress = new Uri(baseAddress);
});

// API client registered last
services.AddSingleton<IApiClient, ApiClient>();
}
Expand All @@ -43,12 +46,14 @@ public class ApiClient : IApiClient
public IVisitClient VisitClient { get; }
public IParticipationClient ParticipationClient { get; }
public ILookupClient LookupClient { get; }
public IPacketClient PacketClient { get; }

public ApiClient(IVisitClient visitClient, IParticipationClient participationClient, ILookupClient lookupClient)
public ApiClient(IVisitClient visitClient, IParticipationClient participationClient, ILookupClient lookupClient, IPacketClient packetClient)
{
VisitClient = visitClient;
ParticipationClient = participationClient;
LookupClient = lookupClient;
PacketClient = packetClient;
}


Expand Down
4 changes: 2 additions & 2 deletions src/UDS.Net.API.Client/IApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
namespace UDS.Net.API.Client
namespace UDS.Net.API.Client
{
public interface IApiClient
{
IVisitClient VisitClient { get; }
IParticipationClient ParticipationClient { get; }
ILookupClient LookupClient { get; }
IPacketClient PacketClient { get; }
}
}

5 changes: 1 addition & 4 deletions src/UDS.Net.API.Client/IBaseClient.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using UDS.Net.Dto;

namespace UDS.Net.API.Client
{
Expand Down
15 changes: 15 additions & 0 deletions src/UDS.Net.API.Client/IPacketClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using UDS.Net.Dto;

namespace UDS.Net.API.Client
{
public interface IPacketClient : IBaseClient<PacketDto>
{
Task<PacketDto> GetPacketWithForms(int id);

Task<int> CountByStatusAndAssignee(string[] statuses, string assignedTo);

Task<List<PacketDto>> GetPacketsByStatusAndAssignee(string[] statuses, string assignedTo, int pageSize = 10, int pageIndex = 1);
}
}
6 changes: 5 additions & 1 deletion src/UDS.Net.API.Client/IVisitClient.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UDS.Net.Dto;

namespace UDS.Net.API.Client
{
public interface IVisitClient : IBaseClient<VisitDto>
{
Task<List<VisitDto>> GetVisitsAtStatus(string[] statuses, int pageSize = 10, int pageIndex = 1);

Task<int> GetCountOfVisitsAtStatus(string[] statuses);

Task<VisitDto> GetWithForm(int id, string formKind);

Task PostWithForm(int id, string formKind, VisitDto dto);
Expand Down
85 changes: 85 additions & 0 deletions src/UDS.Net.API.Client/PacketClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using UDS.Net.Dto;

namespace UDS.Net.API.Client
{
public class PacketClient : AuthenticatedClient<PacketDto>, IPacketClient
{
const string BASEPATH = "Packets";

public PacketClient(HttpClient httpClient) : base(httpClient, BASEPATH)
{
}

public async Task<PacketDto> GetPacketWithForms(int id)
{
var response = await GetRequest($"{_BasePath}/{id}/IncludeForms");

PacketDto dto = JsonSerializer.Deserialize<PacketDto>(response, options);

return dto;
}

public async Task<int> CountByStatusAndAssignee(string[] statuses, string assignedTo)
{
if (statuses != null && statuses.Length > 0)
{
NameValueCollection query = System.Web.HttpUtility.ParseQueryString(string.Empty);

foreach (var status in statuses)
{
query.Add("statuses", status);
}

if (string.IsNullOrWhiteSpace(assignedTo))
{
var response = await GetRequest($"{_BasePath}/Count/ByStatus?{query.ToString()}");

return JsonSerializer.Deserialize<int>(response, options);
}
else
{
var response = await GetRequest($"{_BasePath}/Count/ByStatus?{query.ToString()}&assignedTo={assignedTo}");

return JsonSerializer.Deserialize<int>(response, options);
}
}
return 0;
}

public async Task<List<PacketDto>> GetPacketsByStatusAndAssignee(string[] statuses, string assignedTo, int pageSize = 10, int pageIndex = 1)
{
List<PacketDto> dto = new List<PacketDto>();

if (statuses != null && statuses.Length > 0)
{
NameValueCollection query = System.Web.HttpUtility.ParseQueryString(string.Empty);

foreach (var status in statuses)
{
query.Add("statuses", status);
}

if (string.IsNullOrWhiteSpace(assignedTo))
{
var response = await GetRequest($"{_BasePath}/ByStatus?{query.ToString()}&pageSize={pageSize}&pageIndex={pageIndex}");

dto = JsonSerializer.Deserialize<List<PacketDto>>(response, options);
}
else
{
var response = await GetRequest($"{_BasePath}/ByStatus?{query.ToString()}&assignedTo={assignedTo}&pageSize={pageSize}&pageIndex={pageIndex}");

dto = JsonSerializer.Deserialize<List<PacketDto>>(response, options);
}
}

return dto;
}
}
}

12 changes: 6 additions & 6 deletions src/UDS.Net.API.Client/UDS.Net.API.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<PackageId>UDS.Net.API.Client</PackageId>
<Version>4.0.1</Version>
<Version>4.1.0</Version>
<Authors>Sanders-Brown Center on Aging</Authors>
<Description>UDS client library for using UDS.Net.API</Description>
<Owners>UK-SBCoA</Owners>
<PackageDescription>Client library for API</PackageDescription>
<RepositoryUrl>https://github.com/UK-SBCoA/uniform-data-set-dotnet-api</RepositoryUrl>
<ReleaseVersion>4.0.1</ReleaseVersion>
<ReleaseVersion>4.1.0</ReleaseVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UDS.Net.Dto\UDS.Net.Dto.csproj" />
Expand Down
46 changes: 42 additions & 4 deletions src/UDS.Net.API.Client/VisitClient.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using UDS.Net.Dto;

namespace UDS.Net.API.Client
Expand All @@ -17,6 +15,45 @@ public VisitClient(HttpClient httpClient) : base(httpClient, BASEPATH)
{
}

public async Task<List<VisitDto>> GetVisitsAtStatus(string[] statuses, int pageSize = 10, int pageIndex = 1)
{
List<VisitDto> dto = new List<VisitDto>();

if (statuses != null && statuses.Length > 0)
{
NameValueCollection query = System.Web.HttpUtility.ParseQueryString(string.Empty);

foreach (var status in statuses)
{
query.Add("statuses", status);
}

var response = await GetRequest($"{_BasePath}/ByStatus?{query.ToString()}&pageSize={pageSize}&pageIndex={pageIndex}");

dto = JsonSerializer.Deserialize<List<VisitDto>>(response, options);
}

return dto;
}

public async Task<int> GetCountOfVisitsAtStatus(string[] statuses)
{
if (statuses != null && statuses.Length > 0)
{
NameValueCollection query = System.Web.HttpUtility.ParseQueryString(string.Empty);

foreach (var status in statuses)
{
query.Add("statuses", status);
}

var response = await GetRequest($"{_BasePath}/Count/ByStatus?{query.ToString()}");

return JsonSerializer.Deserialize<int>(response, options);
}
return 0;
}

public async Task<VisitDto> GetWithForm(int id, string formKind)
{
var response = await GetRequest($"{_BasePath}/{id}/Forms/{formKind}");
Expand All @@ -32,6 +69,7 @@ public async Task PostWithForm(int id, string formKind, VisitDto dto)

var response = await PostRequest($"{_BasePath}/{id}/Forms/{formKind}", json);
}

}
}

Loading
Loading