Flavio.Santos.NetCore.ApiResponse 1.0.15

dotnet add package Flavio.Santos.NetCore.ApiResponse --version 1.0.15
                    
NuGet\Install-Package Flavio.Santos.NetCore.ApiResponse -Version 1.0.15
                    
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="Flavio.Santos.NetCore.ApiResponse" Version="1.0.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Flavio.Santos.NetCore.ApiResponse" Version="1.0.15" />
                    
Directory.Packages.props
<PackageReference Include="Flavio.Santos.NetCore.ApiResponse" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Flavio.Santos.NetCore.ApiResponse --version 1.0.15
                    
#r "nuget: Flavio.Santos.NetCore.ApiResponse, 1.0.15"
                    
#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.
#addin nuget:?package=Flavio.Santos.NetCore.ApiResponse&version=1.0.15
                    
Install Flavio.Santos.NetCore.ApiResponse as a Cake Addin
#tool nuget:?package=Flavio.Santos.NetCore.ApiResponse&version=1.0.15
                    
Install Flavio.Santos.NetCore.ApiResponse as a Cake Tool

FDS.NetCore.ApiResponse

๐Ÿš€ FDS.UuidV7.NetCore is a lightweight .NET library for generating UUID v7 (time-based UUIDs) according to the official specification.

NuGet NuGet Downloads License .NET Core

๐Ÿ“ฆ Installation

You can install this package via NuGet Package Manager:

dotnet add package Flavio.Santos.NetCore.ApiResponse --version 1.0.15

Or using Package Manager Console:

Install-Package Flavio.Santos.NetCore.ApiResponse -Version 1.0.15

๐Ÿš€ Usage

Creating a Standard API Response

Adding a New Client
public async Task<Response<ClientDto>> AddAsync(ClientRequestDto request)
{
    // Here I implement the update logic.

    return Result.CreateAdd(msg, clientDto);
}
Deleting a Client
public async Task<Response<bool>> DeleteAsync(Guid id)
{
    // Here I implement the update logic.

    return Result.CreateRemove<bool>(msg);
}
Updating a Client
public async Task<Response<ClientDto>> UpdateAsync(ClientDto request)
{
    // Here I implement the update logic.
    
    return Result.CreateUpdate(updatedClientDto);   
}

Retrieving All Clients

public async Task<Response<IEnumerable<ClientDto>>> GetAllAsync()
{
    // Here I implement the update logic.
    
    return Result.CreateGet<IEnumerable<ClientDto>>(msg, clientDtos);
}

Handling Not Found (404)

public async Task<Response<ClientDto>> GetByIdAsync(Guid id)
{
    var client = await _repository.FindByIdAsync(id);

    if (client is null)
        return Result.CreateNotFound<ClientDto>("Client not found.");

    return Result.CreateGet("Client found.", client);
}

Handling Validation Errors (400)

public async Task<Response<ClientDto>> AddAsync(ClientRequestDto request)
{
    if (string.IsNullOrWhiteSpace(request.Name))
        return Result.CreateValidationError<ClientDto>("Client name is required.");

    // Continuaรงรฃo do fluxo normal se for vรกlido
    var newClient = new ClientDto { Name = request.Name };
    
    return Result.CreateAdd("Client created successfully.", newClient);
}

๐Ÿ“Œ Output Example

Client Not Found (404)
{
  "isSuccess": false,
  "message": "Client not found.",
  "statusCode": 404
}
Client Created Successfully (201)
{
  "isSuccess": true,
  "message": "Client created successfully.",
  "statusCode": 201,
  "data": {
    "id": "bf5d9501-032f-447b-bfaf-8cc4fff19e61",
    "name": "Teste"
  }
}
Client Already Exists (400)
{
  "isSuccess": false,
  "message": "A client with this name already exists.",
  "statusCode": 400
}
Client Deleted Successfully (200)
{
  "isSuccess": true,
  "message": "Client deleted successfully.",
  "statusCode": 200
}

๐ŸŽฏ Features

  • Standardized API response format
  • Built-in status codes and messages
  • Easy integration with Clean Architecture
  • Fully compatible with .NET 8

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ”™ Back to Main README

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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.15 460 3/25/2025
1.0.14 467 3/25/2025
1.0.13 460 3/25/2025
1.0.12 319 3/24/2025
1.0.11 245 3/24/2025
1.0.10 245 3/23/2025
1.0.9 135 3/16/2025
1.0.8 121 3/16/2025
1.0.7 139 3/14/2025
1.0.6 136 3/14/2025
1.0.5 130 3/13/2025
1.0.4 132 3/13/2025
1.0.3 202 3/3/2025
1.0.2 184 3/3/2025
1.0.1 93 3/2/2025
1.0.0 82 3/2/2025