fix potential issue on receipt

This commit is contained in:
Kukks
2023-12-08 11:30:14 +01:00
parent 11f9d8f379
commit a8e43e9350
2 changed files with 6 additions and 3 deletions

View File

@@ -233,7 +233,7 @@ public class TicketTailorClient : IDisposable
[JsonPropertyName("min_per_order")] public int? MinPerOrder { get; set; } [JsonPropertyName("min_per_order")] public int? MinPerOrder { get; set; }
[JsonPropertyName("name")] public string Name { get; set; } [JsonPropertyName("name")] public string? Name { get; set; }
[JsonPropertyName("price")] public decimal Price { get; set; } [JsonPropertyName("price")] public decimal Price { get; set; }

View File

@@ -1,4 +1,7 @@
@using BTCPayServer.Client.Models @using BTCPayServer.Client.Models
@using BTCPayServer.Plugins.TicketTailor
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using BTCPayServer.Abstractions.TagHelpers
@model BTCPayServer.Plugins.TicketTailor.TicketTailorController.TicketReceiptPage @model BTCPayServer.Plugins.TicketTailor.TicketTailorController.TicketReceiptPage
@{ @{
Layout = "_LayoutSimple"; Layout = "_LayoutSimple";
@@ -52,11 +55,11 @@
for (var index = 0; index < Model.Tickets.Length; index++) for (var index = 0; index < Model.Tickets.Length; index++)
{ {
var ticket = Model.Tickets[index]; var ticket = Model.Tickets[index];
var ticketType = Model.Event.TicketTypes.First(type => type.Id == ticket.TicketTypeId); var ticketType = Model.Event.TicketTypes.FirstOrDefault(type => type.Id == ticket.TicketTypeId) ?? new TicketTailorClient.TicketType();
var specificTicketType = Model.Settings?.SpecificTickets? var specificTicketType = Model.Settings?.SpecificTickets?
.FirstOrDefault(specificTicket => specificTicket.TicketTypeId == ticket.TicketTypeId); .FirstOrDefault(specificTicket => specificTicket.TicketTypeId == ticket.TicketTypeId);
ticketType.Name = specificTicketType?.Name ?? ticketType.Name; ticketType.Name = specificTicketType?.Name??ticketType.Name?? ticket.TicketTypeId;
ticketType.Description = specificTicketType?.Description ?? ticketType.Description; ticketType.Description = specificTicketType?.Description ?? ticketType.Description;
<div class="bg-tile m-0 p-3 p-sm-5 rounded "> <div class="bg-tile m-0 p-3 p-sm-5 rounded ">