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

Country Code Lookup #80

Merged
merged 11 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions src/UDS.Net.API.Client/ILookupClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public interface ILookupClient : IBaseClient<LookupDto>
Task<LookupDrugCodeDto> LookupDrugCodes(int pageSize = 10, int pageIndex = 1);

Task<LookupDrugCodeDto> SearchDrugCodes(int pageSize = 10, int pageIndex = 1, bool onlyPopular = true, string? searchTerm = "");

Task<LookupCountryCodeDto> LookupCountryCode(string countryCode);
}
}

10 changes: 10 additions & 0 deletions src/UDS.Net.API.Client/LookupClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public async Task<LookupDrugCodeDto> SearchDrugCodes(int pageSize = 10, int page

return dto;
}

public async Task<LookupCountryCodeDto> LookupCountryCode(string? countryCode)
{
var response = await GetRequest($"{_BasePath}/CountryCode?countryCode={countryCode}");

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

return dto;
}

}
}

4 changes: 2 additions & 2 deletions src/UDS.Net.API.Client/UDS.Net.API.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Library</OutputType>
<PackageId>UDS.Net.API.Client</PackageId>
<Version>4.3.0</Version>
<Version>4.4.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.3.0</ReleaseVersion>
<ReleaseVersion>4.4.0</ReleaseVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
Expand Down
28 changes: 28 additions & 0 deletions src/UDS.Net.API/Controllers/LookupsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,35 @@ public Task Delete(int id)
{
throw new NotImplementedException();
}
[HttpGet("CountryCode", Name ="LookupCountryCode")]
public async Task<LookupCountryCodeDto> LookupCountryCode(string? countryCode)
{
if (string.IsNullOrEmpty(countryCode))
{
return new LookupCountryCodeDto
{
Error = new ErrorDto()
};
}

var country = await _context.CountryCodesLookup.FirstOrDefaultAsync(c => c.Code == countryCode);
if (country == null)
{
return new LookupCountryCodeDto {
Error = new ErrorDto()
};
}

return new LookupCountryCodeDto
{
Id = country.Id,
Code = country.Code,
Country = country.Country,
IsActive = country.IsActive,
ReasonChangedCode = country.ReasonChangedCode

};
}
}
}

2 changes: 2 additions & 0 deletions src/UDS.Net.API/Data/ApiDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class ApiDbContext : DbContext
/* Lookup or reference tables */
public DbSet<DrugCodeLookup> DrugCodesLookup { get; set; }

public DbSet<CountryCodesLookup> CountryCodesLookup { get; set; }

/* SQL Views */
public DbSet<FormStatus> FormStatuses { get; set; }

Expand Down
Loading
Loading