When creating a new apps, the default currency of the store should be used

This commit is contained in:
nicolas.dorier
2021-10-25 16:54:36 +09:00
parent 951bfeefb1
commit a73383cd87
7 changed files with 50 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
using System;
using BTCPayServer.Data;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Models.AppViewModels;
@@ -66,7 +67,11 @@ namespace BTCPayServer.Controllers
[Route("{appId}/settings/crowdfund")]
public async Task<IActionResult> UpdateCrowdfund(string appId, UpdateCrowdfundViewModel vm, string command)
{
if (!string.IsNullOrEmpty(vm.TargetCurrency) && _currencies.GetCurrencyData(vm.TargetCurrency, false) == null)
var app = await GetOwnedApp(appId, AppType.Crowdfund);
if (app == null)
return NotFound();
vm.TargetCurrency = await GetStoreDefaultCurrentIfEmpty(app.StoreDataId, vm.TargetCurrency);
if (_currencies.GetCurrencyData(vm.TargetCurrency, false) == null)
ModelState.AddModelError(nameof(vm.TargetCurrency), "Invalid currency");
try
@@ -116,11 +121,6 @@ namespace BTCPayServer.Controllers
return View(vm);
}
var app = await GetOwnedApp(appId, AppType.Crowdfund);
if (app == null)
return NotFound();
var newSettings = new CrowdfundSettings()
{
Title = vm.Title,