@using Microsoft.AspNetCore.Routing @using BTCPayServer.Plugins.TicketTailor @using Microsoft.AspNetCore.Mvc.TagHelpers @using NBitcoin @model BTCPayServer.Plugins.TicketTailor.TicketTailorViewModel @inject BTCPayServer.Security.ContentSecurityPolicies csp; @{ var nonce = RandomUtils.GetUInt256().ToString().Substring(0, 32); csp.Add("script-src", $"'nonce-{nonce}'"); csp.AllowUnsafeHashes(); Layout = "_LayoutSimple"; var available = Model.Settings.BypassAvailabilityCheck || (Model.Event.Unavailable != "true" && Model.Event.TicketsAvailable == "true"); Model.Settings.SpecificTickets ??= new List(); Context.Request.Query.TryGetValue("accessCode", out var accessCode); }

@Model.Event.Title

@Model.Event.Start.Formatted - @Model.Event.EventEnd.Formatted

@if (Model.Settings.ShowDescription && !string.IsNullOrEmpty(Model.Event.Description)) {
@Safe.Raw(Model.Event.Description)
}
@{ var index = -1; foreach (var groupedTickets in Model.Event.TicketTypes.GroupBy(type => type.GroupId).OrderBy(groupedTickets => Model.Event.TicketGroups.FirstOrDefault(ticketGroup => ticketGroup.Id == groupedTickets.Key)?.SortOrder)) {
@if (!string.IsNullOrEmpty(groupedTickets.Key)) { var group = Model.Event.TicketGroups.First(ticketGroup => ticketGroup.Id == groupedTickets.Key);

@group.Name

} @foreach (var item in groupedTickets) { var availableToShow = new[] {"on_sale", "sold_out", "unavailable"}.Contains(item.Status); if (!string.IsNullOrEmpty(item.AccessCode) && item.AccessCode.Equals(accessCode, StringComparison.InvariantCultureIgnoreCase)) { availableToShow = true; } var specific = false; if (Model.Settings.SpecificTickets?.Any() is true) { var matched = Model.Settings.SpecificTickets.FirstOrDefault(ticket => ticket.TicketTypeId == item.Id); if (matched is null || matched.Hidden) { continue; } if (matched.Price is not null) { item.Price = matched.Price.Value; } if (!string.IsNullOrEmpty(matched.Name)) { item.Name = matched.Name; } if (!string.IsNullOrEmpty(matched.Description)) { item.Description = matched.Description; } availableToShow = true; specific = true; } if (!availableToShow) { continue; } index++; var purchasable = available && (specific || new[] {"on_sale", "locked"}.Contains(item.Status)) && item.Quantity > 0;
@item.Name

@Safe.Raw(item.Description)

@if (purchasable) {
@(item.Price == 0 ? "FREE" : $"{item.Price} {Model.Event.Currency.ToUpperInvariant()}")
} else {
Unavailable
}

}
} }