| | 1 | | using FLP.Core.Context.Constants; |
| | 2 | | using FLP.Core.Context.Shared; |
| | 3 | |
|
| | 4 | | namespace FLP.Core.Context.Main; |
| | 5 | |
|
| | 6 | | public class Bug : BasicModel<Guid> |
| | 7 | | { |
| 18 | 8 | | public Bug() |
| 18 | 9 | | { |
| 18 | 10 | | Status = BugStatus.Open; // Default status for a new bug |
| 18 | 11 | | } |
| 40 | 12 | | public string? Title { get; set; } |
| 30 | 13 | | public string? Description { get; set; } |
| 72 | 14 | | public BugStatus Status { get; private set; } // e.g., "Open", "In Progress", "Resolved" |
| 27 | 15 | | public DateTime? ResolvedAt { get; private set; } // Nullable to allow for unresolved bugs |
| 30 | 16 | | public Guid? AssignedToUserId { get; set; } // Nullable to allow for unassigned bugs |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Updates the status of the bug and sets ResolvedAt if the status is changed to Resolved. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="newStatus"></param> |
| | 22 | | public void UpdateStatus(BugStatus newStatus) |
| 4 | 23 | | { |
| 4 | 24 | | Status = newStatus; |
| | 25 | | // Automatically set ResolvedAt when status changes to Resolved |
| 4 | 26 | | if (IsBugResolvedOrClosed(newStatus)) |
| 2 | 27 | | { |
| 2 | 28 | | ResolvedAt = DateTime.UtcNow; // Set resolved time when status is changed to Resolved |
| 2 | 29 | | } |
| | 30 | | else |
| 2 | 31 | | { |
| 2 | 32 | | ResolvedAt = null; // Clear resolved time for statuses other than Resolved |
| 2 | 33 | | } |
| 4 | 34 | | } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Checks if the bug status is either Resolved or Closed. |
| | 38 | | /// </summary> |
| | 39 | | /// <param name="status"></param> |
| | 40 | | /// <returns></returns> |
| | 41 | | public static bool IsBugResolvedOrClosed(BugStatus status) |
| 8 | 42 | | => status == BugStatus.Resolved || status == BugStatus.Closed; |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Checks if the current bug status is either Resolved or Closed. |
| | 46 | | /// </summary> |
| | 47 | | /// <returns></returns> |
| | 48 | | public bool IsBugResolvedOrClosed() |
| 0 | 49 | | { |
| 0 | 50 | | return IsBugResolvedOrClosed(Status); |
| 0 | 51 | | } |
| | 52 | | } |