Etymon.Result 1.0.2

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

// Install Etymon.Result as a Cake Tool
#tool nuget:?package=Etymon.Result&version=1.0.2                

Step 1:

CLI: dotnet add package Etymon.Result
Package Manager: Install-Package Etymon.Result

Step 2:

Implement service

public async Task<Result<Model>> GetItem(int id)
{
    var data = await _db.Items.Where(i => i.Id == id).FirstOrDefaultAsync();

    if(data == null)
    {
        return new Error("DataNotFound", "Item your are looking for is not available.");
    }
    return data;
}

Step 3:
Here is sample controller code:

[Route("get-all-items")]
[HttpGet]
public async Task<IActionResult> GetItemsById(int id)
{
    var result = await _service.GetItems(id);
    if (!result.IsSuccess)
        return NotFound(result);
    return Ok(result );
}

Step 4:

Here is sample output when success:

{
  "data": [
    {
      "Id": 1,
      "ItemName": "some item",
      "IsActive": false
    }
  ],
  "error": null,
  "isSuccess": true,
  "isFailure": false
}

Here is sample output when error:

{
  "data": null,
  "error": {
    "code": "DataNotFound",
    "message": "Item your are looking for is not available."
  },
  "isSuccess": false,
  "isFailure": true
}
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.