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                
#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                

Teranga.Core

NuGet NuGet

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

  1. Register the service in your application:
using Teranga.Core.Extensions;

services.AddTerangaCore();
  1. 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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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


Made with โค๏ธ for Senegal

Product 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.

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