btcpayserver/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs
d11n ff79a31066
Refactoring: Move AppItem to Client lib and use the class for item list (#6258)
* Refactoring: Move AppItem to Client lib and use the class for item list

This makes it available for the app, which would otherwise have to replicate the model. Also uses the proper class for the item/perk list of the app models.

* Remove unused app item payment methods property

* Do not ignore nullable values in JSON

* Revert to use Newtonsoft types
2024-11-05 11:49:30 +09:00

75 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using BTCPayServer.Client.Models;
using BTCPayServer.Models;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace BTCPayServer.Plugins.PointOfSale.Models
{
public class ViewPointOfSaleViewModel
{
public class CurrencyInfoData
{
public bool Prefixed { get; set; }
public string CurrencySymbol { get; set; }
public string ThousandSeparator { get; set; }
public string DecimalSeparator { get; set; }
public int Divisibility { get; set; }
public bool SymbolSpace { get; set; }
}
public StoreBrandingViewModel StoreBranding { get; set; }
public string StoreName { get; set; }
public CurrencyInfoData CurrencyInfo { get; set; }
public PosViewType ViewType { get; set; }
public bool ShowItems { get; set; }
public bool ShowCustomAmount { get; set; }
public bool ShowDiscount { get; set; }
public bool ShowSearch { get; set; } = true;
public bool ShowCategories { get; set; } = true;
public bool EnableTips { get; set; }
public string Step { get; set; }
public string Title { get; set; }
AppItem[] _Items;
public AppItem[] Items
{
get
{
return _Items;
}
set
{
_Items = value;
UpdateGroups();
}
}
private void UpdateGroups()
{
AllCategories = null;
if (Items is null)
return;
var groups = Items.SelectMany(g => g.Categories ?? Array.Empty<string>())
.ToHashSet()
.Select(o => new KeyValuePair<string, string>(o, o))
.ToList();
if (groups.Count == 0)
return;
groups.Insert(0, new KeyValuePair<string, string>("All", "*"));
AllCategories = new SelectList(groups, "Value", "Key", "*");
}
public string CurrencyCode { get; set; }
public string CurrencySymbol { get; set; }
public string AppId { get; set; }
public string ButtonText { get; set; }
public string CustomButtonText { get; set; }
public string CustomTipText { get; set; }
public int[] CustomTipPercentages { get; set; }
public string Description { get; set; }
public SelectList AllCategories { get; set; }
public string StoreId { get; set; }
}
}