Skip to content

Commit 14ae7ee

Browse files
committed
2 parents 679bd17 + ae7abc3 commit 14ae7ee

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
[![SimpleResults-FluentValidation](https://img.shields.io/nuget/vpre/SimpleResults.FluentValidation?label=SimpleResults.FluentValidation%20-%20nuget&color=red)](https://www.nuget.org/packages/SimpleResults.FluentValidation)
1010
[![downloads](https://img.shields.io/nuget/dt/SimpleResults.FluentValidation?color=yellow)](https://www.nuget.org/packages/SimpleResults.FluentValidation)
1111

12-
[![SimpleResults-logo](https://raw.githubusercontent.com/MrDave1999/SimpleResults/master/SimpleResults-logo.png)](https://github.com/MrDave1999/SimpleResults)
12+
[![SimpleResults-logo](https://raw.githubusercontent.com/DevD4v3/SimpleResults/master/SimpleResults-logo.png)](https://github.com/DevD4v3/SimpleResults)
1313

1414
A simple library to implement the Result pattern for returning from services. It also provides a mechanism for translating the Result object to an [ActionResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.actionresult?view=aspnetcore-7.0) or [IResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iresult?view=aspnetcore-7.0).
1515

1616
> This library was inspired by [Ardalis.Result](https://github.com/ardalis/Result).
1717
18-
See the [API documentation](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.html) for more information on this project.
18+
See the [API documentation](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.html) for more information on this project.
1919

2020
## Index
2121

@@ -160,7 +160,7 @@ With any of these types you can handle errors and at the same time generate erro
160160

161161
This approach provides a new way to generate an error using return statements without the need to throw exceptions.
162162

163-
See the [API documentation](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.html) for more information on these types.
163+
See the [API documentation](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.html) for more information on these types.
164164

165165
### Using the `Result` type
166166

@@ -353,9 +353,9 @@ public class UserService
353353

354354
### Integration with ASP.NET Core
355355

356-
You can convert the Result object to a [Microsoft.AspNetCore.Mvc.ActionResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.actionresult-1?view=aspnetcore-7.0) using the [ToActionResult](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.ResultExtensions.ToActionResult.html) extension method.
356+
You can convert the Result object to a [Microsoft.AspNetCore.Mvc.ActionResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.actionresult-1?view=aspnetcore-7.0) using the [ToActionResult](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.ResultExtensions.ToActionResult.html) extension method.
357357

358-
You need to install the [SimpleResults.AspNetCore](https://www.nuget.org/packages/SimpleResults.AspNetCore) package to have access to the extension method. See the [ResultExtensions](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.ResultExtensions.html#methods) class to find all extension methods.
358+
You need to install the [SimpleResults.AspNetCore](https://www.nuget.org/packages/SimpleResults.AspNetCore) package to have access to the extension method. See the [ResultExtensions](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.ResultExtensions.html#methods) class to find all extension methods.
359359

360360
**Example:**
361361
```cs
@@ -394,11 +394,11 @@ public class UserController
394394
=> _userService.GetAll().ToActionResult();
395395
}
396396
```
397-
See the [API documentation](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.ResultExtensions.html#methods) for a list of available extension methods.
397+
See the [API documentation](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.ResultExtensions.html#methods) for a list of available extension methods.
398398

399399
#### Using TranslateResultToActionResult as an action filter
400400

401-
You can also use the [TranslateResultToActionResult](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.TranslateResultToActionResultAttribute.html) filter to translate the Result object to [ActionResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.actionresult?view=aspnetcore-7.0).
401+
You can also use the [TranslateResultToActionResult](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.TranslateResultToActionResultAttribute.html) filter to translate the Result object to [ActionResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.actionresult?view=aspnetcore-7.0).
402402

403403
`TranslateResultToActionResultAttribute` class will internally call the `ToActionResult` method and perform the translation.
404404

@@ -418,11 +418,11 @@ public class UserController
418418
```
419419
The return value of `Get` action is a `Result<User>`. **After the action is executed**, the filter (i.e. `TranslateResultToActionResult`) will run and translate the `Result<User>` to [ActionResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.actionresult?view=aspnetcore-7.0).
420420

421-
[See the source code](https://github.com/MrDave1999/SimpleResults/blob/e0b4bf02c77c02862f0a95ded268ee05cbc6d033/src/AspNetCore/TranslateResultToActionResultAttribute.cs#L12), it is very simple.
421+
[See the source code](https://github.com/DevD4v3/SimpleResults/blob/e0b4bf02c77c02862f0a95ded268ee05cbc6d033/src/AspNetCore/TranslateResultToActionResultAttribute.cs#L12), it is very simple.
422422

423423
#### Add action filter as global
424424

425-
If you do not want to use the filter on each controller, you can add it globally for all controllers (see [sample](https://github.com/MrDave1999/SimpleResults/blob/e0b4bf02c77c02862f0a95ded268ee05cbc6d033/samples/SimpleResults.Example.AspNetCore/Program.cs#L10C1-L14C4)).
425+
If you do not want to use the filter on each controller, you can add it globally for all controllers (see [sample](https://github.com/DevD4v3/SimpleResults/blob/e0b4bf02c77c02862f0a95ded268ee05cbc6d033/samples/SimpleResults.Example.AspNetCore/Program.cs#L10C1-L14C4)).
426426
```cs
427427
builder.Services.AddControllers(options =>
428428
{
@@ -436,7 +436,7 @@ This way you no longer need to add the `TranslateResultToActionResult` attribute
436436

437437
As of version 2.3.0, a feature has been added to convert the Result object to an implementation of [Microsoft.AspNetCore.Http.IResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iresult?view=aspnetcore-7.0).
438438

439-
You only need to use the extension method called [ToHttpResult](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.ResultExtensions.ToHttpResult.html). See the [ResultExtensions](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.ResultExtensions.html#methods) class to find all extension methods.
439+
You only need to use the extension method called [ToHttpResult](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.ResultExtensions.ToHttpResult.html). See the [ResultExtensions](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.ResultExtensions.html#methods) class to find all extension methods.
440440

441441
**Example:**
442442
```cs
@@ -464,7 +464,7 @@ public static class UserEndpoint
464464
}
465465
}
466466
```
467-
You can also use the [TranslateResultToHttpResult](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.TranslateResultToHttpResultFilter.html) filter to translate the Result object to an implementation of [IResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iresult?view=aspnetcore-7.0).
467+
You can also use the [TranslateResultToHttpResult](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.TranslateResultToHttpResultFilter.html) filter to translate the Result object to an implementation of [IResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iresult?view=aspnetcore-7.0).
468468

469469
`TranslateResultToHttpResultFilter` class will internally call the `ToHttpResult` method and perform the translation.
470470

@@ -487,15 +487,15 @@ public static class UserEndpoint
487487
```
488488
The endpoint handler returns a `Result<User>`. After the handler is executed, the filter (i.e. `TranslateResultToHttpResult`) will run and translate the `Result<User>` to an implementation of [IResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iresult?view=aspnetcore-7.0).
489489

490-
[See the source code](https://github.com/MrDave1999/SimpleResults/blob/25387945f57241dadad3baf52886ab59949c98fa/src/AspNetCore/TranslateResultToHttpResultFilter.cs#L26), it is very simple.
490+
[See the source code](https://github.com/DevD4v3/SimpleResults/blob/25387945f57241dadad3baf52886ab59949c98fa/src/AspNetCore/TranslateResultToHttpResultFilter.cs#L26), it is very simple.
491491

492492
#### Validating with the ModelState property
493493

494494
[SimpleResults.AspNetCore](https://www.nuget.org/packages/SimpleResults.AspNetCore) package also adds extension methods for the [ModelStateDictionary](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.modelstatedictionary?view=aspnetcore-7.0) type.
495495

496-
See the [ModelStateDictionaryExtensions](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.SRModelStateDictionaryExtensions.html) class to find all extension methods.
496+
See the [ModelStateDictionaryExtensions](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.SRModelStateDictionaryExtensions.html) class to find all extension methods.
497497

498-
The `ModelStateDictionary` type contains the validation errors that are displayed to the client. Somehow these errors must be included in an instance of type [Result](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.Result.html).
498+
The `ModelStateDictionary` type contains the validation errors that are displayed to the client. Somehow these errors must be included in an instance of type [Result](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.Result.html).
499499

500500
##### Manual validation
501501

@@ -520,7 +520,7 @@ public class OrderController : ControllerBase
520520
}
521521
}
522522
```
523-
In this example a manual validation is performed with `ModelState.IsFailed()` (an extension method), so if the model state is failed, an invalid result type is returned. What `ModelState.Invalid()` does is to convert the instance of `ModelStateDictionary` to an instance of type [Result](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.Result.html), so in the result object the validation errors will be added.
523+
In this example a manual validation is performed with `ModelState.IsFailed()` (an extension method), so if the model state is failed, an invalid result type is returned. What `ModelState.Invalid()` does is to convert the instance of `ModelStateDictionary` to an instance of type [Result](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.Result.html), so in the result object the validation errors will be added.
524524

525525
After the controller action is executed, the `TranslateResultToActionResult` filter will translate the Result object to an instance of type `ActionResult`.
526526

@@ -546,11 +546,11 @@ public class OrderController : ControllerBase
546546
}
547547
}
548548
```
549-
`ModelState.BadRequest()` has a behavior similar to `ModelState.Invalid()`, the difference is that the first one returns an instance of type [BadRequestObjectResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.badrequestobjectresult?view=aspnetcore-7.0) in which contains the instance of type [Result](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.Result.html).
549+
`ModelState.BadRequest()` has a behavior similar to `ModelState.Invalid()`, the difference is that the first one returns an instance of type [BadRequestObjectResult](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.badrequestobjectresult?view=aspnetcore-7.0) in which contains the instance of type [Result](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.Result.html).
550550

551551
##### Automatic validation
552552

553-
You need to make a setting in the `Program.cs` to convert the instance of type `ModelStateDictionary` to an instance of type [Result](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.Result.html) when the model validation fails.
553+
You need to make a setting in the `Program.cs` to convert the instance of type `ModelStateDictionary` to an instance of type [Result](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.Result.html) when the model validation fails.
554554

555555
**Example:**
556556
```cs
@@ -620,22 +620,22 @@ public class UserService
620620
}
621621
}
622622
```
623-
See the [API documentation](https://mrdave1999.github.io/SimpleResults/api/SimpleResults.SRFluentValidationResultExtensions.html#methods) for a list of available extension methods.
623+
See the [API documentation](https://DevD4v3.github.io/SimpleResults/api/SimpleResults.SRFluentValidationResultExtensions.html#methods) for a list of available extension methods.
624624

625625
## Samples
626626

627627
You can find a complete and functional example in these projects:
628-
- [SimpleResults.Example](https://github.com/MrDave1999/SimpleResults/tree/master/samples/SimpleResults.Example)
629-
- [SimpleResults.Example.NativeAOT](https://github.com/MrDave1999/SimpleResults/tree/master/samples/SimpleResults.Example.NativeAOT)
630-
- [SimpleResults.Example.AspNetCore](https://github.com/MrDave1999/SimpleResults/tree/master/samples/SimpleResults.Example.AspNetCore)
631-
- [SimpleResults.Example.Web.Tests](https://github.com/MrDave1999/SimpleResults/tree/master/samples/SimpleResults.Example.Web.Tests)
632-
- [SimpleResults.Example.FluentValidation](https://github.com/MrDave1999/SimpleResults/tree/master/samples/SimpleResults.Example/FluentValidation)
633-
- [Double-V-Partners](https://github.com/MrDave1999/double-v-partners/tree/master/backend/src/Features/Users)
634-
- [Orders.Sample](https://github.com/MrDave1999/orders-sample/tree/master/src/Application/Features/Orders)
628+
- [SimpleResults.Example](https://github.com/DevD4v3/SimpleResults/tree/master/samples/SimpleResults.Example)
629+
- [SimpleResults.Example.NativeAOT](https://github.com/DevD4v3/SimpleResults/tree/master/samples/SimpleResults.Example.NativeAOT)
630+
- [SimpleResults.Example.AspNetCore](https://github.com/DevD4v3/SimpleResults/tree/master/samples/SimpleResults.Example.AspNetCore)
631+
- [SimpleResults.Example.Web.Tests](https://github.com/DevD4v3/SimpleResults/tree/master/samples/SimpleResults.Example.Web.Tests)
632+
- [SimpleResults.Example.FluentValidation](https://github.com/DevD4v3/SimpleResults/tree/master/samples/SimpleResults.Example/FluentValidation)
633+
- [Double-V-Partners](https://github.com/DevD4v3/double-v-partners/tree/master/backend/src/Features/Users)
634+
- [Orders.Sample](https://github.com/DevD4v3/orders-sample/tree/master/src/Application/Features/Orders)
635635

636636
## Language settings
637637

638-
`SimpleResults` has resources that contain response messages. [See the source code](https://github.com/MrDave1999/SimpleResults/tree/23f5fdb4af10195b182ace9ff78fb4fbf4fa9768/src/Core/Resources).
638+
`SimpleResults` has resources that contain response messages. [See the source code](https://github.com/DevD4v3/SimpleResults/tree/23f5fdb4af10195b182ace9ff78fb4fbf4fa9768/src/Core/Resources).
639639

640640
At the moment there are only two resources:
641641
- `ResponseMessages.resx`. It contains messages in English.

0 commit comments

Comments
 (0)