Redirect to Stores page if creating invoice before creating a store

This commit is contained in:
NicolasDorier
2017-09-15 13:49:36 +09:00
parent efcda9a45e
commit d86e8695a0
4 changed files with 35 additions and 4 deletions

View File

@@ -127,7 +127,13 @@ namespace BTCPayServer.Controllers
[BitpayAPIConstraint(false)]
public async Task<IActionResult> CreateInvoice()
{
return View(new CreateInvoiceModel() { Stores = await GetStores(GetUserId()) });
var stores = await GetStores(GetUserId());
if(stores.Count() == 0)
{
StatusMessage = "Error: You need to create at least one store before creating a transaction";
return RedirectToAction(nameof(StoresController.ListStores), "Stores");
}
return View(new CreateInvoiceModel() { Stores = stores });
}
[HttpPost]