diff --git a/WebApi_data_value/Services/BackgroundService.cs b/WebApi_data_value/Services/BackgroundService.cs index 5489451..f870e0d 100644 --- a/WebApi_data_value/Services/BackgroundService.cs +++ b/WebApi_data_value/Services/BackgroundService.cs @@ -66,7 +66,7 @@ public class ParkingUpdateService : BackgroundService { Timestamp = DateTime.Now, TotalParkingSpaces = totalParkingSpaces, - RemainingSpaces = remainingSpaces, + RemainingSpaces = Math.Max(remainingSpaces, 0), // 確保儲存時不為負數 MonthlyRentSpaces = monthlyRentNumber, TemporaryRentSpaces = Math.Abs(temporaryRentNumber), DayOfWeek = DateTime.Now.ToString("dddd", new CultureInfo("zh-TW"))