Notim.Outputs 2.0.0

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

// Install Notim.Outputs as a Cake Tool
#tool nuget:?package=Notim.Outputs&version=2.0.0

Outputs

This is a Basic Wrapper for use case Outputs, commom used with Mediatr Output or CQRS Patterns

get in nuget

you can install with nuget package manager

dotnet add package Notim.Outputs

the usage is very simple, you only need to instace Output with classe that you need to transport.

[...]

var output = new Output<ClassThatYouNeedToTransport>();

if (something is notGood) {
  output.AddErrorMessage("something is not good");
}
else{
  output.AddMessage("Success");
  output.AddResult(new ClassThatYouNeedToTransport(argsThenYouNeed));
}

return output;

[...]

you have the functionality to determine the error type to filter if you want to return a especific status code or retries on your topic consumers;

example:

[...]

var output = new Output<ClassThatYouNeedToTransport>();

if (something is notGood because external service is offline)
{
  output.AddError(new Error(ErrorType.ExternalServiceUnavailable, "something is not good"));
}
else if (something is notGood because you dont find result on database)
{
  output.AddError(new Error(ErrorType.ResourceNotFound, "something is not good"));
}
else
{
  output.AddMessage("Success");
  output.AddResult(new ClassThatYouNeedToTransport(argsThenYouNeed));
}

return output;
[...]

controller:

[HttpGet("/")]
public async Task<IActionResult> GetOrder(ClassThatYouNeedToTransport input, CancelationToken cancelationToken)

  var output = await _usecase.Execute(input, cancelationToken);
  
  if (!output.IsValid && output.Error.ErrorType is ErrorType.ExternalServiceUnavailable)
    return BadGateway(output.ErrorMessages);
  
  if (!output.IsValid && output.Error.ErrorType is ErrorType.ResourceNotFound)
    return NotFound(output.ErrorMessages);
  
  return Ok(output.GetResult());
}

After version 2 you can use the single line Build Form to create Output

success use case output

var output = Output<ObjectThatYouWantToReturn>.WithSuccess(message, new ObjectThatYouWantToReturn());

error use case output

var output = Output<ObjectThatYouWantToReturn>.WithError(errorMessage);

error object use case output

var output = Output<ObjectThatYouWantToReturn>.WithError(new Error(ErrorType.ExternalServiceUnavailable, errorMessage));

Contribution

If you would like to contribute to this project, follow these steps:

  1. Create a branch for your changes (git checkout -b feature/MyFeature)
  2. Commit your changes (git commit -am 'feat: add a feature')
  3. Push to the branch (git push origin feature/MyFeature)
  4. Open a Pull Request

some issues you can talk with me paulino.joaovitor@yahoo.com.br

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Notim.Outputs:

Package Downloads
Notim.Outputs.FluentValidation

extensions to use Output with ValidationResult from Fluent Validation

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 308 3/5/2024
2.0.3 260 11/8/2023
2.0.2 485 11/8/2023
2.0.1 102 11/7/2023
2.0.0 93 11/7/2023
1.0.2 128 11/7/2023
1.0.1 124 11/7/2023
1.0.0 161 11/7/2023