This commit is contained in:
Kukks
2023-01-18 13:27:56 +01:00
parent df1c30e654
commit 9140f9b3ff
13 changed files with 379 additions and 240 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -11,8 +12,10 @@ using BTCPayServer.Client;
using BTCPayServer.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using NBitcoin;
using NBXplorer;
using XX;
namespace BTCPayServer.Plugins.LiquidPlus.Controllers
{
@@ -262,3 +265,18 @@ public class GenerateLiquidImportScripts
}
}
}
namespace XX
{
public static class ModelStateExtensions
{
public static void AddModelError<TModel, TProperty>(this TModel source,
Expression<Func<TModel, TProperty>> ex,
string message,
ControllerBase controller)
{
var provider = (ModelExpressionProvider)controller.HttpContext.RequestServices.GetService(typeof(ModelExpressionProvider));
var key = provider.GetExpressionText(ex);
controller.ModelState.AddModelError(key, message);
}
}
}