Fix View app on Crowdfunding (#1141)

This commit is contained in:
nicolas.dorier 2019-11-14 21:13:41 +09:00
parent bcb85e2084
commit 57a6949565
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
2 changed files with 20 additions and 11 deletions

View file

@ -68,7 +68,7 @@ namespace BTCPayServer.Controllers
}
[HttpPost]
[Route("{appId}/settings/crowdfund")]
public async Task<IActionResult> UpdateCrowdfund(string appId, UpdateCrowdfundViewModel vm)
public async Task<IActionResult> UpdateCrowdfund(string appId, UpdateCrowdfundViewModel vm, string command = null)
{
if (!string.IsNullOrEmpty( vm.TargetCurrency) && _currencies.GetCurrencyData(vm.TargetCurrency, false) == null)
ModelState.AddModelError(nameof(vm.TargetCurrency), "Invalid currency");
@ -156,6 +156,9 @@ namespace BTCPayServer.Controllers
app.TagAllInvoices = vm.UseAllStoreInvoices;
app.SetSettings(newSettings);
if (command == "save")
{
await _AppService.UpdateOrCreateApp(app);
_EventAggregator.Publish(new AppUpdated()
@ -167,5 +170,11 @@ namespace BTCPayServer.Controllers
TempData[WellKnownTempData.SuccessMessage] = "App updated";
return RedirectToAction(nameof(UpdateCrowdfund), new { appId });
}
else if (command == "viewapp")
{
return RedirectToAction(nameof(AppsPublicController.ViewCrowdfund), "AppsPublic", new { appId });
}
return NotFound();
}
}
}

View file

@ -215,9 +215,9 @@
</div>
<input type="hidden" asp-for="NotificationEmailWarning" />
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Save Settings" id="SaveSettings" />
<button name="command" type="submit" class="btn btn-primary" value="save" id="SaveSettings">Save settings</button>
<a class="btn btn-secondary" target="_blank" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm">Invoices</a>
<a class="btn btn-secondary" target="_blank" asp-action="ViewCrowdfund" asp-controller="AppsPublic" asp-route-appId="@Model.AppId" id="ViewApp">View App</a>
<button name="command" type="submit" value="viewapp" class="btn btn-secondary" id="ViewApp">View App</button>
<a class="btn btn-secondary" target="_blank" asp-action="ListApps">Back to the app list</a>
</div>
</form>