Skip to content

Commit f936f11

Browse files
author
Steve Hansen
committed
fix: make PhotoCategory flexible to handle unknown enum values
Changed Category to store as string and parse on access, defaulting to General if the value doesn't match a known category.
1 parent 44423c0 commit f936f11

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/FleetClaim.Core/Models/IncidentReport.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,16 @@ public class PhotoAttachment
305305
public string? Caption { get; set; }
306306

307307
/// <summary>
308-
/// Photo category for organization
308+
/// Photo category for organization (stored as string for flexibility)
309309
/// </summary>
310-
public PhotoCategory Category { get; set; } = PhotoCategory.General;
310+
[System.Text.Json.Serialization.JsonPropertyName("category")]
311+
public string? CategoryString { get; set; }
312+
313+
/// <summary>
314+
/// Parsed photo category (defaults to General if unknown)
315+
/// </summary>
316+
[System.Text.Json.Serialization.JsonIgnore]
317+
public PhotoCategory Category => Enum.TryParse<PhotoCategory>(CategoryString, true, out var cat) ? cat : PhotoCategory.General;
311318

312319
/// <summary>
313320
/// When the photo was uploaded

0 commit comments

Comments
 (0)