From 555273aed127736f1b333e9698b8deff64ea466c Mon Sep 17 00:00:00 2001 From: Florian Mihalits Date: Wed, 6 Aug 2025 16:46:32 +0200 Subject: [PATCH] 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. --- gehGassi.Dto/Walks/PublicWalkRequestAcceptDto.cs | 2 +- gehGassi.Dto/Walks/WalkCreateDto.cs | 2 +- gehGassi.Web/Controllers/Api/ApiWalksController.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gehGassi.Dto/Walks/PublicWalkRequestAcceptDto.cs b/gehGassi.Dto/Walks/PublicWalkRequestAcceptDto.cs index 54bb222..1ae4a5d 100644 --- a/gehGassi.Dto/Walks/PublicWalkRequestAcceptDto.cs +++ b/gehGassi.Dto/Walks/PublicWalkRequestAcceptDto.cs @@ -40,6 +40,6 @@ namespace gehGassi.Dto.Walks /// /// Zahlungsart für den Walk /// - public WalkPaymentTypeDto PaymentType { get; set; } + public WalkPaymentTypeDto? PaymentType { get; set; } } } diff --git a/gehGassi.Dto/Walks/WalkCreateDto.cs b/gehGassi.Dto/Walks/WalkCreateDto.cs index 9cc8ebb..3b19c39 100644 --- a/gehGassi.Dto/Walks/WalkCreateDto.cs +++ b/gehGassi.Dto/Walks/WalkCreateDto.cs @@ -105,6 +105,6 @@ namespace gehGassi.Dto.Walks /// /// Zahlungsart für den Walk /// - public WalkPaymentTypeDto PaymentType { get; set; } + public WalkPaymentTypeDto? PaymentType { get; set; } } } diff --git a/gehGassi.Web/Controllers/Api/ApiWalksController.cs b/gehGassi.Web/Controllers/Api/ApiWalksController.cs index 6977608..740ee77 100644 --- a/gehGassi.Web/Controllers/Api/ApiWalksController.cs +++ b/gehGassi.Web/Controllers/Api/ApiWalksController.cs @@ -1039,7 +1039,7 @@ namespace gehGassi.Web.Controllers.Api walk.CompletedInfo = string.Empty; walk.Defactation = false; walk.PaymentStatus = PaymentStatus.Pending; - walk.PaymentType = (WalkPaymentType)model.PaymentType; + walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay; walk.UpdatedAt = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow; @@ -3630,7 +3630,7 @@ namespace gehGassi.Web.Controllers.Api walk.CompletedInfo = string.Empty; walk.Defactation = false; walk.PaymentStatus = PaymentStatus.Pending; - walk.PaymentType = (WalkPaymentType)model.PaymentType; + walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay; walk.UpdatedAt = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow; @@ -3810,7 +3810,7 @@ namespace gehGassi.Web.Controllers.Api walk.CompletedInfo = string.Empty; walk.Defactation = false; walk.PaymentStatus = PaymentStatus.None; - walk.PaymentType = (WalkPaymentType)model.PaymentType; + walk.PaymentType = model.PaymentType != null ? (WalkPaymentType)model.PaymentType : WalkPaymentType.MangoPay; walk.UpdatedAt = DateTimeOffset.UtcNow; walk.Created = DateTimeOffset.UtcNow;