Clone Payment Requests (#648)

* Clone Payment Requests

closes #615

* Do not save clone instantly
This commit is contained in:
Andrew Camilleri
2019-03-07 06:27:16 +01:00
committed by Nicolas Dorier
parent 2b567de5c1
commit 06406c0695
3 changed files with 25 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using NBitpayClient;
namespace BTCPayServer.Controllers
@@ -198,7 +199,7 @@ namespace BTCPayServer.Controllers
new
{
StatusMessage =
"Payment request could not be removed. Any request that has generated invoices cannot be removed."
"Error: Payment request could not be removed. Any request that has generated invoices cannot be removed."
});
}
}
@@ -309,5 +310,23 @@ namespace BTCPayServer.Controllers
{
return _UserManager.GetUserId(User);
}
[HttpGet]
[Route("{id}/clone")]
public async Task<IActionResult> ClonePaymentRequest(string id)
{
var result = await EditPaymentRequest(id);
if (result is ViewResult viewResult)
{
var model = (UpdatePaymentRequestViewModel)viewResult.Model;
model.Id = null;
model.Title = $"Clone of {model.Title}";
return View("EditPaymentRequest", model);
}
return NotFound();
}
}
}