mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
507 B
15 lines
507 B
using System.Diagnostics.CodeAnalysis; |
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
namespace ErsatzTV.Extensions; |
|
|
|
[SuppressMessage("ReSharper", "VSTHRD003")] |
|
public static class OptionToActionResult |
|
{ |
|
public static IActionResult ToActionResult<T>(this Option<T> option) => |
|
option.Match<IActionResult>( |
|
t => new OkObjectResult(t), |
|
() => new NotFoundResult()); |
|
|
|
public static Task<IActionResult> ToActionResult<T>(this Task<Option<T>> option) => option.Map(ToActionResult); |
|
}
|
|
|