From c917aec401bf858b956f97d76b637a717e7b40d9 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Tue, 31 May 2022 22:25:04 -0700 Subject: [PATCH] Add PosViewType enum --- BTCPayServer.Client/Models/CreateAppRequest.cs | 14 +++++++++++++- .../GreenField/GreenfieldAppsController.cs | 4 +--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/BTCPayServer.Client/Models/CreateAppRequest.cs b/BTCPayServer.Client/Models/CreateAppRequest.cs index 28b912cf9..2534438bb 100644 --- a/BTCPayServer.Client/Models/CreateAppRequest.cs +++ b/BTCPayServer.Client/Models/CreateAppRequest.cs @@ -1,5 +1,16 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + namespace BTCPayServer.Client.Models { + public enum PosViewType + { + Static, + Cart, + Light, + Print + } + public class CreateAppRequest { public string AppName { get; set; } @@ -12,7 +23,8 @@ namespace BTCPayServer.Client.Models public string Title { get; set; } = null; public string Description { get; set; } = null; public string Template { get; set; } = null; - public string DefaultView { get; set; } = null; + [JsonConverter(typeof(StringEnumConverter))] + public PosViewType DefaultView { get; set; } public bool ShowCustomAmount { get; set; } = true; public bool ShowDiscount { get; set; } = true; public bool EnableTips { get; set; } = true; diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs index dbf172ea8..3ae50a620 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldAppsController.cs @@ -52,12 +52,10 @@ namespace BTCPayServer.Controllers.Greenfield AppType = AppType.PointOfSale.ToString() }; - Enum.TryParse(request.DefaultView, out PosViewType defaultView); - appData.SetSettings(new PointOfSaleSettings { Title = request.Title, - DefaultView = defaultView, + DefaultView = (Services.Apps.PosViewType)request.DefaultView, ShowCustomAmount = request.ShowCustomAmount, ShowDiscount = request.ShowDiscount, EnableTips = request.EnableTips,