Skip to content

Commit a8970bb

Browse files
committed
ResultErro added to ViewOption
1 parent 49ca637 commit a8970bb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Danom.Mvc/DanomController.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ public class DanomController
1616
/// <param name="option"></param>
1717
/// <param name="viewName"></param>
1818
/// <param name="noneAction"></param>
19+
/// <param name="errors"></param>
1920
/// <returns></returns>
2021
public IActionResult ViewOption<T>(
2122
Option<T> option,
2223
string? viewName = null,
23-
Func<IActionResult>? noneAction = null) =>
24-
option.Match(
24+
Func<IActionResult>? noneAction = null,
25+
ResultErrors? errors = null)
26+
{
27+
if (errors is not null)
28+
{
29+
ModelState.AddResultErrors(errors);
30+
}
31+
32+
return option.Match(
2533
some: x =>
2634
{
2735
if (viewName is not null)
@@ -42,6 +50,7 @@ public IActionResult ViewOption<T>(
4250

4351
return NotFound();
4452
});
53+
}
4554

4655
/// <summary>
4756
/// Renders the specified view with the specified model, and add the

0 commit comments

Comments
 (0)