Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Core/Resgrid.Model/Events/IncidentCommandEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public class IncidentClosedEvent
public string IncidentCommandId { get; set; }
}

/// <summary>A previously closed incident command was reopened.</summary>
public class IncidentReopenedEvent
{
public int DepartmentId { get; set; }
public int CallId { get; set; }
public string IncidentCommandId { get; set; }
public string Reason { get; set; }
public string ReopenedByUserId { get; set; }
}

/// <summary>Raised when a resource is assigned to a command structure node.</summary>
public class IncidentResourceAssignedEvent
{
Expand Down
3 changes: 3 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/CommandStructureNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public class CommandStructureNode : IEntity, IChangeTracked
/// <summary>Optional incident need this lane is fulfilling (FK to IncidentNeeds).</summary>
public string LinkedNeedId { get; set; }

/// <summary>Optional named incident map attached to this lane (FK to IncidentMaps) — e.g. the area it is working.</summary>
public string LinkedMapId { get; set; }

/// <summary>Primary lane lead when they are a Resgrid user; null for external leads.</summary>
public string PrimaryLeadUserId { get; set; }

Expand Down
29 changes: 29 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/IncidentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,39 @@ public class IncidentCommand : IEntity, IChangeTracked

public string CurrentCommanderUserId { get; set; }

/// <summary>Optional commander-supplied display name for the incident (falls back to the call name in UIs).</summary>
public string Name { get; set; }

/// <summary>Free-form description of where the ICP/HQ (command post) is ("Front lobby of 123 Main St").</summary>
public string CommandPostLocationText { get; set; }

public string CommandPostLatitude { get; set; }

public string CommandPostLongitude { get; set; }

/// <summary>Free-form description of where Staging is located.</summary>
public string StagingLocationText { get; set; }

public string StagingLatitude { get; set; }

public string StagingLongitude { get; set; }

/// <summary>Free-form description of where Rehab is located.</summary>
public string RehabLocationText { get; set; }

public string RehabLatitude { get; set; }

public string RehabLongitude { get; set; }

/// <summary>Saved incident-map view: center latitude (set once the IC pins the map's framing).</summary>
public string MapCenterLatitude { get; set; }

/// <summary>Saved incident-map view: center longitude.</summary>
public string MapCenterLongitude { get; set; }

/// <summary>Saved incident-map view: zoom level (0-22); null until the incident map is created.</summary>
public string MapZoomLevel { get; set; }

public string IncidentActionPlan { get; set; }

/// <summary>NIMS/ICS escalation level for the incident (department defined).</summary>
Expand Down
3 changes: 3 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/IncidentCommandBoard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class IncidentCommandBoard

public List<IncidentMapAnnotation> Annotations { get; set; } = new List<IncidentMapAnnotation>();

/// <summary>Named tactical maps for the incident (the main map lives on the Command itself).</summary>
public List<IncidentMap> Maps { get; set; } = new List<IncidentMap>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Kody Rules low

Mutable collection exposure: the Maps property publicly exposes a mutable List<IncidentMap>, allowing callers to alter the underlying collection unexpectedly. Expose the collection as IReadOnlyList<IncidentMap> while keeping the internal mutable list for initialization.

Kody rule violation: Use IReadOnlyList for immutable collections

Prompt for LLM

File Core/Resgrid.Model/IncidentCommand/IncidentCommandBoard.cs:

Line 26:

Mutable collection exposure: the `Maps` property publicly exposes a mutable `List<IncidentMap>`, allowing callers to alter the underlying collection unexpectedly. Expose the collection as `IReadOnlyList<IncidentMap>` while keeping the internal mutable list for initialization.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.


/// <summary>Personnel accountability / PAR status (from the Checkin feature) for the incident.</summary>
public List<PersonnelCallCheckInStatus> Accountability { get; set; } = new List<PersonnelCallCheckInStatus>();

Expand Down
2 changes: 2 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/IncidentCommandChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class IncidentCommandChanges

public List<IncidentMapAnnotation> Annotations { get; set; } = new List<IncidentMapAnnotation>();

public List<IncidentMap> Maps { get; set; } = new List<IncidentMap>();

public List<IncidentRoleAssignment> Roles { get; set; } = new List<IncidentRoleAssignment>();

public List<IncidentAdHocUnit> AdHocUnits { get; set; } = new List<IncidentAdHocUnit>();
Expand Down
34 changes: 32 additions & 2 deletions Core/Resgrid.Model/IncidentCommand/IncidentCommandEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public enum TacticalObjectiveStatus
InProgress = 2
}

/// <summary>How a completed tactical objective turned out (recorded at close-out).</summary>
public enum TacticalObjectiveOutcome
{
NotSet = 0,
Successful = 1,
Partial = 2,
Unsuccessful = 3
}

/// <summary>Category of an incident need (resource/logistics request tracked at the command level).</summary>
public enum IncidentNeedCategory
{
Expand All @@ -55,7 +64,22 @@ public enum IncidentNeedCategory
Medical = 2,
Equipment = 3,
Staffing = 4,
Other = 5
Other = 5,

/// <summary>
/// A request for SPECIFIC Resgrid entities (units/users/roles/groups) that get added to the call
/// and dispatched individually as "requested by command". See <see cref="IncidentNeedEntity"/>.
/// </summary>
Entity = 6
}

/// <summary>What kind of Resgrid entity an <see cref="IncidentNeedEntity"/> requests.</summary>
public enum NeedEntityKind
{
Unit = 0,
User = 1,
Role = 2,
Group = 3
}

/// <summary>Fulfillment state of an incident need.</summary>
Expand Down Expand Up @@ -148,6 +172,12 @@ public enum CommandLogEntryType
NeedMet = 33,
ObjectiveProgressUpdated = 34,
LaneLeadChanged = 35,
CommandDetailsUpdated = 36
CommandDetailsUpdated = 36,

/// <summary>A previously closed command was reopened (the reopen reason is embedded in the description).</summary>
CommandReopened = 37,

/// <summary>The incident map's saved view (center/zoom) was created or changed.</summary>
MapViewUpdated = 38
}
}
90 changes: 90 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/IncidentCommandSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;

namespace Resgrid.Model
{
/// <summary>
/// List-card projection of an incident command for the IC app's incident list: identity, lifecycle timing,
/// resolved commander name, locations, and active resource counts. Not persisted (composed by the service).
/// </summary>
public class IncidentCommandSummary
{
public string IncidentCommandId { get; set; }

public int DepartmentId { get; set; }

public int CallId { get; set; }

/// <summary>Commander-supplied incident name; null when unnamed (UIs fall back to the call name).</summary>
public string Name { get; set; }

public string CallName { get; set; }

public string CallNumber { get; set; }

public string CallAddress { get; set; }

/// <summary>Maps to <see cref="IncidentCommandStatus"/>.</summary>
public int Status { get; set; }

public DateTime EstablishedOn { get; set; }

public DateTime? ClosedOn { get; set; }

public string CommanderUserId { get; set; }

/// <summary>Resolved commander full name (falls back to the user id when the profile is unavailable).</summary>
public string CommanderName { get; set; }

public string CommandPostLocationText { get; set; }

public string CommandPostLatitude { get; set; }

public string CommandPostLongitude { get; set; }

/// <summary>Active (unreleased) personnel assignments placed in a lane or staging.</summary>
public int AssignedPersonnelCount { get; set; }

/// <summary>Active (unreleased) unit assignments placed in a lane or staging.</summary>
public int AssignedUnitCount { get; set; }
}

/// <summary>
/// Field bag for <c>IIncidentCommandService.UpdateCommandInfoAsync</c>. Null members are left unchanged;
/// an empty string clears the stored value. Any location whose text is set while its coordinates are
/// blank is geocoded server-side on save.
/// </summary>
public class IncidentCommandInfoUpdate
{
public string Name { get; set; }

/// <summary>Corrected incident start time (UTC); null leaves the original EstablishedOn.</summary>
public DateTime? EstablishedOn { get; set; }

public DateTime? EstimatedEndOn { get; set; }

/// <summary>When true, a null <see cref="EstimatedEndOn"/> clears the stored value instead of leaving it.</summary>
public bool ClearEstimatedEndOn { get; set; }

public string ImportantInformation { get; set; }

public int? IcsLevel { get; set; }

public string CommandPostLocationText { get; set; }

public string CommandPostLatitude { get; set; }

public string CommandPostLongitude { get; set; }

public string StagingLocationText { get; set; }

public string StagingLatitude { get; set; }

public string StagingLongitude { get; set; }

public string RehabLocationText { get; set; }

public string RehabLatitude { get; set; }

public string RehabLongitude { get; set; }
}
}
72 changes: 72 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/IncidentMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace Resgrid.Model
{
/// <summary>
/// A named tactical map for an incident — its own saved framing (center + zoom) and markup
/// (annotations reference it via <see cref="IncidentMapAnnotation.IncidentMapId"/>), with an optional
/// expiry. Lanes can attach one via <see cref="CommandStructureNode.LinkedMapId"/>. The incident's
/// MAIN map lives on <see cref="IncidentCommand"/> itself (MapCenter*/MapZoomLevel, null map id).
/// </summary>
public class IncidentMap : IEntity, IChangeTracked
{
public string IncidentMapId { get; set; }

public string IncidentCommandId { get; set; }

public int DepartmentId { get; set; }

public int CallId { get; set; }

public string Name { get; set; }

public string Description { get; set; }

public string CenterLatitude { get; set; }

public string CenterLongitude { get; set; }

/// <summary>Zoom level (0-22); null until the framing has been pinned.</summary>
public string ZoomLevel { get; set; }

/// <summary>Optional expiry after which the map is stale (kept, but flagged in UIs).</summary>
public DateTime? ExpiresOn { get; set; }

public string CreatedByUserId { get; set; }

public DateTime CreatedOn { get; set; }

public string UpdatedByUserId { get; set; }

public DateTime? UpdatedOn { get; set; }

/// <summary>Soft-delete tombstone so removals propagate to offline clients.</summary>
public DateTime? DeletedOn { get; set; }

/// <summary>Change cursor for offline delta sync + last-write-wins; stamped on every write.</summary>
public DateTime? ModifiedOn { get; set; }

[NotMapped]
public string TableName => "IncidentMaps";

[NotMapped]
public string IdName => "IncidentMapId";

[NotMapped]
public int IdType => 1;

[NotMapped]
[JsonIgnore]
public object IdValue
{
get { return IncidentMapId; }
set { IncidentMapId = (string)value; }
}

[NotMapped]
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName" };
}
}
58 changes: 58 additions & 0 deletions Core/Resgrid.Model/IncidentCommand/IncidentNeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,62 @@ public object IdValue
[NotMapped]
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName" };
}

/// <summary>
/// Append-only audit row for one fulfillment change on an <see cref="IncidentNeed"/>: status and/or
/// fill-quantity transition, the caller's note ("Engine 1 from mutual aid"), who made it, and when.
/// </summary>
public class IncidentNeedUpdate : IEntity
{
public string IncidentNeedUpdateId { get; set; }

public string IncidentNeedId { get; set; }

public string IncidentCommandId { get; set; }

public int DepartmentId { get; set; }

public int CallId { get; set; }

/// <summary>Maps to <see cref="IncidentNeedStatus"/>.</summary>
public int PreviousStatus { get; set; }

/// <summary>Maps to <see cref="IncidentNeedStatus"/>.</summary>
public int NewStatus { get; set; }

public int PreviousQuantityFulfilled { get; set; }

public int NewQuantityFulfilled { get; set; }

/// <summary>Caller-supplied context for the change (which resource filled it, why it was called off, ...).</summary>
public string Note { get; set; }

public string CreatedByUserId { get; set; }

/// <summary>Resolved display name for CreatedByUserId; filled at read time, never persisted.</summary>
[NotMapped]
public string CreatedByUserName { get; set; }

public DateTime CreatedOn { get; set; }

[NotMapped]
public string TableName => "IncidentNeedUpdates";

[NotMapped]
public string IdName => "IncidentNeedUpdateId";

[NotMapped]
public int IdType => 1;

[NotMapped]
[JsonIgnore]
public object IdValue
{
get { return IncidentNeedUpdateId; }
set { IncidentNeedUpdateId = (string)value; }
}

[NotMapped]
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName", "CreatedByUserName" };
}
}
Loading
Loading