mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
POS: Updates from code review
This commit is contained in:
@@ -2312,8 +2312,6 @@ donation:
|
|||||||
Assert.Equal("hello", vmpos.Title);
|
Assert.Equal("hello", vmpos.Title);
|
||||||
|
|
||||||
var publicApps = user.GetController<AppsPublicController>();
|
var publicApps = user.GetController<AppsPublicController>();
|
||||||
Assert.IsType<RedirectToActionResult>(publicApps.ViewPointOfSale(appId).Result);
|
|
||||||
|
|
||||||
var vmview =
|
var vmview =
|
||||||
Assert.IsType<ViewPointOfSaleViewModel>(Assert
|
Assert.IsType<ViewPointOfSaleViewModel>(Assert
|
||||||
.IsType<ViewResult>(publicApps.ViewPointOfSale(appId, PosViewType.Cart).Result).Model);
|
.IsType<ViewResult>(publicApps.ViewPointOfSale(appId, PosViewType.Cart).Result).Model);
|
||||||
|
|||||||
@@ -41,23 +41,9 @@ namespace BTCPayServer.Controllers
|
|||||||
private readonly UserManager<ApplicationUser> _UserManager;
|
private readonly UserManager<ApplicationUser> _UserManager;
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("/apps/{appId}/pos")]
|
[Route("/apps/{appId}/pos/{viewType?}")]
|
||||||
[XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.AllowAll)]
|
[XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.AllowAll)]
|
||||||
public async Task<IActionResult> ViewPointOfSale(string appId)
|
public async Task<IActionResult> ViewPointOfSale(string appId, PosViewType? viewType = null)
|
||||||
{
|
|
||||||
var app = await _AppService.GetApp(appId, AppType.PointOfSale);
|
|
||||||
if (app == null)
|
|
||||||
return NotFound();
|
|
||||||
var settings = app.GetSettings<PointOfSaleSettings>();
|
|
||||||
PosViewType viewType = settings.EnableShoppingCart? PosViewType.Cart : settings.DefaultView;
|
|
||||||
|
|
||||||
return RedirectToAction(nameof(ViewPointOfSale), new { appId, viewType });
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Route("/apps/{appId}/pos/{viewType}")]
|
|
||||||
[XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.AllowAll)]
|
|
||||||
public async Task<IActionResult> ViewPointOfSale(string appId, PosViewType viewType)
|
|
||||||
{
|
{
|
||||||
var app = await _AppService.GetApp(appId, AppType.PointOfSale);
|
var app = await _AppService.GetApp(appId, AppType.PointOfSale);
|
||||||
if (app == null)
|
if (app == null)
|
||||||
@@ -65,12 +51,13 @@ namespace BTCPayServer.Controllers
|
|||||||
var settings = app.GetSettings<PointOfSaleSettings>();
|
var settings = app.GetSettings<PointOfSaleSettings>();
|
||||||
var numberFormatInfo = _AppService.Currencies.GetNumberFormatInfo(settings.Currency) ?? _AppService.Currencies.GetNumberFormatInfo("USD");
|
var numberFormatInfo = _AppService.Currencies.GetNumberFormatInfo(settings.Currency) ?? _AppService.Currencies.GetNumberFormatInfo("USD");
|
||||||
double step = Math.Pow(10, -(numberFormatInfo.CurrencyDecimalDigits));
|
double step = Math.Pow(10, -(numberFormatInfo.CurrencyDecimalDigits));
|
||||||
|
viewType ??= settings.EnableShoppingCart ? PosViewType.Cart : settings.DefaultView;
|
||||||
|
|
||||||
return View("PointOfSale/" + viewType, new ViewPointOfSaleViewModel()
|
return View("PointOfSale/" + viewType, new ViewPointOfSaleViewModel()
|
||||||
{
|
{
|
||||||
Title = settings.Title,
|
Title = settings.Title,
|
||||||
Step = step.ToString(CultureInfo.InvariantCulture),
|
Step = step.ToString(CultureInfo.InvariantCulture),
|
||||||
ViewType = viewType,
|
ViewType = (PosViewType)viewType,
|
||||||
ShowCustomAmount = settings.ShowCustomAmount,
|
ShowCustomAmount = settings.ShowCustomAmount,
|
||||||
ShowDiscount = settings.ShowDiscount,
|
ShowDiscount = settings.ShowDiscount,
|
||||||
EnableTips = settings.EnableTips,
|
EnableTips = settings.EnableTips,
|
||||||
@@ -98,7 +85,7 @@ namespace BTCPayServer.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/apps/{appId}/pos/{viewType}")]
|
[Route("/apps/{appId}/pos/{viewType?}")]
|
||||||
[XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.AllowAll)]
|
[XFrameOptionsAttribute(XFrameOptionsAttribute.XFrameOptions.AllowAll)]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
[EnableCors(CorsPolicies.All)]
|
[EnableCors(CorsPolicies.All)]
|
||||||
|
|||||||
Reference in New Issue
Block a user