pires11d / CleanHandling

A clean way to deal with business logic and flows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CleanHandling

A clean way to deal with business logic and flows!

Write only the code that is important for your business rules, this library handle the errors flows, reducing boilerplate code.

First get the result from a mathod. Ex:

var result = await Result.Try(_session.SaveChangesAsync());

Then you can use the methods from the ResultExtension like:

var stringValueResult = result.Then(val => val.ToString());
Console.WriteLine(stringValueResult); // implicit convert result -> string
result.When(val => val is not null,
     @then: val => Result.From("Not Null"),
     @else: val => Result.From("Null"))

Real examples in the Finance Controlinator

image image

About

A clean way to deal with business logic and flows

License:MIT License


Languages

Language:C# 100.0%