Teranga.Core
1.0.0
dotnet add package Teranga.Core --version 1.0.0
NuGet\Install-Package Teranga.Core -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Teranga.Core" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Teranga.Core --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Teranga.Core, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Teranga.Core as a Cake Addin #addin nuget:?package=Teranga.Core&version=1.0.0 // Install Teranga.Core as a Cake Tool #tool nuget:?package=Teranga.Core&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Teranga.Core
Teranga.Core is a .NET library providing easy access to Senegal's administrative data (regions, departments, and communes).
Features
- โจ Complete administrative data of Senegal
- ๐ High performance and thread-safe
- ๐ Asynchronous operations
- ๐ฏ Zero configuration required
- ๐ฆ Embedded data
- ๐งช Fully tested
Installation
Via Package Manager Console
Install-Package Teranga.Core
Via .NET CLI
dotnet add package Teranga.Core
Quick Start
- Register the service in your application:
using Teranga.Core.Extensions;
services.AddTerangaCore();
- Use it in your application:
public class RegionsController : ControllerBase
{
private readonly ITerangaService _terangaService;
public RegionsController(ITerangaService terangaService)
{
_terangaService = terangaService;
}
[HttpGet]
public async Task<IActionResult> GetAllRegions()
{
var regions = await _terangaService.GetAllRegionsAsync();
return Ok(regions);
}
}
Usage Examples
Getting All Regions
var regions = await _terangaService.GetAllRegionsAsync();
Finding a Specific Region
var dakar = await _terangaService.GetRegionByCodeAsync("DK");
Getting Departments in a Region
var departments = await _terangaService.GetDepartmentsByRegionAsync("DK");
Finding a Specific Commune
var commune = await _terangaService.GetCommuneByCodeAsync("DK1C1");
Administrative Codes
Structure
- Regions: 2 characters (e.g., "DK" for Dakar)
- Departments: 3 characters (e.g., "DK1")
- Communes: 5 characters (e.g., "DK1C1")
Examples
DK -> Dakar (Region)
DK1 -> Dakar (Department)
DK1C17-> Plateau (Commune)
API Reference
ITerangaService
public interface ITerangaService
{
Task<TerangaData> GetTerangaDataAsync();
Task<IEnumerable<Region>> GetAllRegionsAsync();
Task<Region?> GetRegionByCodeAsync(string code);
Task<IEnumerable<Department>> GetDepartmentsByRegionAsync(string regionCode);
Task<Department?> GetDepartmentByCodeAsync(string code);
Task<IEnumerable<Commune>> GetCommunesByDepartmentAsync(string departmentCode);
Task<Commune?> GetCommuneByCodeAsync(string code);
}
Performance
- Initial load time: < 100ms
- Simple queries: < 10ms
- Complex queries: < 50ms
- Memory usage: < 10MB
Best Practices
Do's
// Use dependency injection
services.AddTerangaCore();
// Handle null results
var region = await service.GetRegionByCodeAsync(code);
if (region == null) return NotFound();
// Use async/await
await service.GetAllRegionsAsync();
Don'ts
// Don't create instances manually
var service = new TerangaService(); // โ
// Don't ignore null checks
return Ok(await service.GetRegionByCodeAsync(code)); // โ
// Don't block on async calls
service.GetAllRegionsAsync().Result; // โ
Error Handling
try
{
var region = await _service.GetRegionByCodeAsync(code);
if (region == null)
{
// Handle not found case
return NotFound();
}
return Ok(region);
}
catch (TerangaException ex)
{
// Handle specific exceptions
_logger.LogError(ex, "Error retrieving region");
return StatusCode(500, "An error occurred");
}
Logging
The service uses Microsoft.Extensions.Logging:
services.AddLogging(builder =>
{
builder.AddConsole();
builder.AddDebug();
});
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Running Tests
dotnet test
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- ๐ซ Report issues on GitHub
- ๐ Star the repo if you find it helpful
- ๐ค Contribute via pull requests
Acknowledgments
- Data provided by official Senegalese administrative sources
- Built with .NET 8.0
- Inspired by the need for standardized administrative data access
๐ Contact
- Email : ibrahimadiaw1997@gmail.com
- X : @IbrahimaDiaw
- GitHub : @IbrahimaDiaw
- LinkedIn : @ibrahimaDiaw
Made with โค๏ธ for Senegal
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Logging (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 88 | 12/15/2024 |
Version initiale