AppCore.Net 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package AppCore.Net --version 0.1.1                
NuGet\Install-Package AppCore.Net -Version 0.1.1                
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="AppCore.Net" Version="0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AppCore.Net --version 0.1.1                
#r "nuget: AppCore.Net, 0.1.1"                
#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 AppCore.Net as a Cake Addin
#addin nuget:?package=AppCore.Net&version=0.1.1

// Install AppCore.Net as a Cake Tool
#tool nuget:?package=AppCore.Net&version=0.1.1                

⚙️ AppCore.Net

Publish NuGet DotNet MIT License

Introduction

AppCore.Net is a library for simplifying .NET API development, offering standardized service operations, flexible routing, and seamless chaining of service results for cleaner and more maintainable code.

  • Streamlined API Controllers: Simplifies response handling with attributes like [ApiResponse], providing clear and consistent HTTP status documentation.
  • Centralized Result Management: ServiceResult enables clear success or failure status, making error handling and conditional logic seamless.
  • Exception Handling Made Easy: ApiException provides a straightforward way to handle specific HTTP error codes, improving code clarity.
  • Result Chaining: Methods return ServiceResult or typed results, allowing for intuitive chaining and cleaner service logic.
  • Enhanced Maintainability: Standardized patterns reduce boilerplate code, making APIs easier to build, understand, and maintain.

Getting Started

To get started with AppCore, just add the package using NuGet:

dotnet add package AppCore.Net

How it Works?

Here's how to create a controller :

public class CoffeeController(CoffeeService service) : ApiController
{
    [HttpPost]
    [ApiResponse(200, "Coffee prepared successfully.")]
    [ApiResponse(400, "An error occurred during the preparation process.")]
    public ActionResult PrepareCoffee() => service.PrepareCoffee();
}

And here's how to create an action in a service, each function returns a ServiceResult, and can be chained.

public class CoffeeService
{
    public ServiceResult DoSomething()
    {
        return ServiceResult.Error("Something happened!", HttpStatusCode.Conflict);
    }

    public ServiceResult PrepareCoffee()
    {
        var doSomethingResult = DoSomething();
        if (doSomethingResult == false) return doSomethingResult;
        
        return ServiceResult.Ok("The coffee is now DONE!");
    }
}

Contribute to AppCore

See CONTRIBUTING.md for best practices and instructions on setting up your development environment to work on AppCore.

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
0.1.3 82 12/6/2024
0.1.2 90 12/6/2024
0.1.1 78 12/6/2024
0.1.0 84 12/6/2024