EfCore.GenericServices.AspNetCore 1.2.0

A support library to the EfCore.GenericServices library. It transfers IStatusGeneric errors into ASP.NET Core's ModelState

There is a newer version of this package available.
See the version list below for details.
Install-Package EfCore.GenericServices.AspNetCore -Version 1.2.0
dotnet add package EfCore.GenericServices.AspNetCore --version 1.2.0
<PackageReference Include="EfCore.GenericServices.AspNetCore" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EfCore.GenericServices.AspNetCore --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

EfCore.GenericServices.AspNetCore

This library provides converters from EfCore.GenericService and EfCore.GenericBizRunner status results to into two ASP.NET Core formats.

  1. CopyErrorsToModelState which convert IStatusGeneric errors into ASP.NET Core's ModelState.
    Useful when working html/razor pages.
  2. Response which turns a IStatusGeneric, with optional result, into a Web API formatted return.
    • HTTP 200 (OK) with a result and the status Message string
    • HTTP 404 (Not found) if data was null
    • HTTP 400 (Bad request) with errors in the same format as Web API uses.

Response formats

  • Valid status, i.e. no errors: HTTP 200 (OK) with json result with properly message containing the Message sent back by GenericServices/GenericBizRunner
  • Status has errors: HTTP 400 (Bad request) with errors in Web API format (see below)
  • Valid status, with result:
    • Results is null: HTTP 404 (Not Found) with json result with properly message containing the Message sent back by GenericServices/GenericBizRunner
    • Results is not null: HTTP 200 (OK) with json result with properly message containing the Message, and results containing the results

Web API error format

If using Web API in ASP.NET Core 2.1 or higher the default action is to validate the input to the action
and return a HTTP 400 (Bad request) with the errors send as a dictionary format in json, with the name of
the property that had the error and an array of the error messages for that property.
See example below:

{
    "": [
        "Global error message"
    ],
    "MyPropery": [
        "The property is required",
        "Another error on the same property"
    ]
}

The Response extension method uses that format to return IStatusGeneric so that you have a common error response format.

MIT licence

EfCore.GenericServices.AspNetCore

This library provides converters from EfCore.GenericService and EfCore.GenericBizRunner status results to into two ASP.NET Core formats.

  1. CopyErrorsToModelState which convert IStatusGeneric errors into ASP.NET Core's ModelState.
    Useful when working html/razor pages.
  2. Response which turns a IStatusGeneric, with optional result, into a Web API formatted return.
    • HTTP 200 (OK) with a result and the status Message string
    • HTTP 404 (Not found) if data was null
    • HTTP 400 (Bad request) with errors in the same format as Web API uses.

Response formats

  • Valid status, i.e. no errors: HTTP 200 (OK) with json result with properly message containing the Message sent back by GenericServices/GenericBizRunner
  • Status has errors: HTTP 400 (Bad request) with errors in Web API format (see below)
  • Valid status, with result:
    • Results is null: HTTP 404 (Not Found) with json result with properly message containing the Message sent back by GenericServices/GenericBizRunner
    • Results is not null: HTTP 200 (OK) with json result with properly message containing the Message, and results containing the results

Web API error format

If using Web API in ASP.NET Core 2.1 or higher the default action is to validate the input to the action
and return a HTTP 400 (Bad request) with the errors send as a dictionary format in json, with the name of
the property that had the error and an array of the error messages for that property.
See example below:

{
    "": [
        "Global error message"
    ],
    "MyPropery": [
        "The property is required",
        "Another error on the same property"
    ]
}

The Response extension method uses that format to return IStatusGeneric so that you have a common error response format.

MIT licence

Release Notes

- New Feature: Added `Response` extension methods to turn `IGenericStatus` into standard Web API responses
     - New Feature: Now supports EfCore.GenericBizRunner, providing the same conversions as for EfCore.GenericServices

GitHub repositories (1+)

Showing the top 1 GitHub repositories that depend on EfCore.GenericServices.AspNetCore:

Repository Stars
JonPSmith/PermissionAccessControl2
Version 2 of example application to go with articles on feature and data authorization

Version History

Version Downloads Last updated
4.1.1 73 6/19/2020
4.1.0 990 3/18/2020
4.0.0 1,804 10/14/2019
4.0.0-preview001 120 2/28/2020
3.0.2 11,185 9/5/2018
3.0.1 252 8/31/2018
3.0.0 260 8/22/2018
2.0.0 304 8/14/2018
1.2.1 358 7/30/2018
1.2.0 278 7/25/2018
1.1.0 1,218 6/7/2018
1.0.0 381 4/12/2018
Show less