using System.Collections.Generic;
using System.Linq;
using BTCPayServer.Services.Rates;
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace BTCPayServer.TagHelpers
{
[HtmlTargetElement("input", Attributes = "currency-selection")]
public class CurrenciesSuggestionsTagHelper : TagHelper
{
private readonly CurrencyNameTable _currencies;
public CurrenciesSuggestionsTagHelper(CurrencyNameTable currencies)
{
_currencies = currencies;
}
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.Attributes.RemoveAll("currency-selection");
output.PostElement.AppendHtml("");
output.Attributes.Add("list", "currency-selection-suggestion");
base.Process(context, output);
}
private void InsertAt(List currencies, string code, int idx)
{
var curr = currencies.FirstOrDefault(c => c.Code == code);
currencies.Remove(curr);
currencies.Insert(idx, curr);
}
}
}