| | | 1 | | namespace RoleRadar.Domain.Notes; |
| | | 2 | | |
| | | 3 | | public enum NoteStatus |
| | | 4 | | { |
| | | 5 | | Active, |
| | | 6 | | Archived |
| | | 7 | | } |
| | | 8 | | |
| | | 9 | | public static class NoteStatusExtensions |
| | | 10 | | { |
| | 4360 | 11 | | public static string ToWireString(this NoteStatus status) => status switch |
| | 4360 | 12 | | { |
| | 4328 | 13 | | NoteStatus.Active => "active", |
| | 30 | 14 | | NoteStatus.Archived => "archived", |
| | 2 | 15 | | _ => throw new ArgumentOutOfRangeException(nameof(status), status, "Unknown note status.") |
| | 4360 | 16 | | }; |
| | | 17 | | |
| | | 18 | | public static NoteStatus FromWireString(string value) |
| | | 19 | | { |
| | 2756 | 20 | | if (string.IsNullOrWhiteSpace(value)) |
| | | 21 | | { |
| | 2 | 22 | | throw new ArgumentException("Note status cannot be null or whitespace.", nameof(value)); |
| | | 23 | | } |
| | | 24 | | |
| | 2754 | 25 | | return value.Trim().ToLowerInvariant() switch |
| | 2754 | 26 | | { |
| | 2744 | 27 | | "active" => NoteStatus.Active, |
| | 8 | 28 | | "archived" => NoteStatus.Archived, |
| | 2 | 29 | | _ => throw new ArgumentException($"Unsupported note status '{value}'. Expected 'active' or 'archived'.", nam |
| | 2754 | 30 | | }; |
| | | 31 | | } |
| | | 32 | | } |