Make PaymentType nullable and handle null cases

Updated the PaymentType property in PublicWalkRequestAcceptDto and WalkCreateDto to be nullable.
Modified ApiWalksController to safely assign PaymentType, using a default value when null to prevent runtime errors.
This commit is contained in:
Florian Mihalits 2025-08-06 16:46:32 +02:00
parent b481a3999a
commit 555273aed1
3 changed files with 5 additions and 5 deletions

View File

@ -40,6 +40,6 @@ namespace gehGassi.Dto.Walks
/// <summary> /// <summary>
/// Zahlungsart für den Walk /// Zahlungsart für den Walk
/// </summary> /// </summary>
public WalkPaymentTypeDto PaymentType { get; set; } public WalkPaymentTypeDto? PaymentType { get; set; }
} }
} }

View File

@ -105,6 +105,6 @@ namespace gehGassi.Dto.Walks
/// <summary> /// <summary>
/// Zahlungsart für den Walk /// Zahlungsart für den Walk
/// </summary> /// </summary>
public WalkPaymentTypeDto PaymentType { get; set; } public WalkPaymentTypeDto? PaymentType { get; set; }
} }
} }

View File

@ -1039,7 +1039,7 @@ namespace gehGassi.Web.Controllers.Api
walk.CompletedInfo = string.Empty; walk.CompletedInfo = string.Empty;
walk.Defactation = false; walk.Defactation = false;
walk.PaymentStatus = PaymentStatus.Pending; walk.PaymentStatus = PaymentStatus.Pending;
walk.PaymentType = (WalkPaymentType)model.PaymentType; walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay;
walk.UpdatedAt = DateTimeOffset.UtcNow; walk.UpdatedAt = DateTimeOffset.UtcNow;
walk.Created = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;
@ -3630,7 +3630,7 @@ namespace gehGassi.Web.Controllers.Api
walk.CompletedInfo = string.Empty; walk.CompletedInfo = string.Empty;
walk.Defactation = false; walk.Defactation = false;
walk.PaymentStatus = PaymentStatus.Pending; walk.PaymentStatus = PaymentStatus.Pending;
walk.PaymentType = (WalkPaymentType)model.PaymentType; walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay;
walk.UpdatedAt = DateTimeOffset.UtcNow; walk.UpdatedAt = DateTimeOffset.UtcNow;
walk.Created = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;
@ -3810,7 +3810,7 @@ namespace gehGassi.Web.Controllers.Api
walk.CompletedInfo = string.Empty; walk.CompletedInfo = string.Empty;
walk.Defactation = false; walk.Defactation = false;
walk.PaymentStatus = PaymentStatus.None; walk.PaymentStatus = PaymentStatus.None;
walk.PaymentType = (WalkPaymentType)model.PaymentType; walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay;
walk.UpdatedAt = DateTimeOffset.UtcNow; walk.UpdatedAt = DateTimeOffset.UtcNow;
walk.Created = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;