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
2 changed files with 20 additions and 11 deletions

View File

@@ -68,7 +68,7 @@ namespace BTCPayServer.Controllers
} }
[HttpPost] [HttpPost]
[Route("{appId}/settings/crowdfund")] [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) if (!string.IsNullOrEmpty( vm.TargetCurrency) && _currencies.GetCurrencyData(vm.TargetCurrency, false) == null)
ModelState.AddModelError(nameof(vm.TargetCurrency), "Invalid currency"); ModelState.AddModelError(nameof(vm.TargetCurrency), "Invalid currency");
@@ -156,16 +156,25 @@ namespace BTCPayServer.Controllers
app.TagAllInvoices = vm.UseAllStoreInvoices; app.TagAllInvoices = vm.UseAllStoreInvoices;
app.SetSettings(newSettings); app.SetSettings(newSettings);
await _AppService.UpdateOrCreateApp(app);
_EventAggregator.Publish(new AppUpdated() if (command == "save")
{ {
AppId = appId, await _AppService.UpdateOrCreateApp(app);
StoreId = app.StoreDataId,
Settings = newSettings _EventAggregator.Publish(new AppUpdated()
}); {
TempData[WellKnownTempData.SuccessMessage] = "App updated"; AppId = appId,
return RedirectToAction(nameof(UpdateCrowdfund), new {appId}); StoreId = app.StoreDataId,
Settings = newSettings
});
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> </div>
<input type="hidden" asp-for="NotificationEmailWarning" /> <input type="hidden" asp-for="NotificationEmailWarning" />
<div class="form-group"> <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="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> <a class="btn btn-secondary" target="_blank" asp-action="ListApps">Back to the app list</a>
</div> </div>
</form> </form>