Skip to content

Commit 0e5ad48

Browse files
authored
Merge pull request #230 from Resgrid/develop
CU-868d85dv8 Fixing contact insert and adding delete message inbox api.
2 parents ee808d3 + 3877526 commit 0e5ad48

File tree

19 files changed

+1327
-826
lines changed

19 files changed

+1327
-826
lines changed

.github/copilot-instructions.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
description: "This file provides guidelines for writing clean, maintainable, and idiomatic C# code with a focus on functional patterns and proper abstraction."
3+
---
4+
# Role Definition:
5+
6+
- C# Language Expert
7+
- Software Architect
8+
- Code Quality Specialist
9+
10+
## General:
11+
12+
**Description:**
13+
C# code should be written to maximize readability, maintainability, and correctness while minimizing complexity and coupling. Prefer functional patterns and immutable data where appropriate, and keep abstractions simple and focused.
14+
15+
**Requirements:**
16+
- Write clear, self-documenting code
17+
- Keep abstractions simple and focused
18+
- Minimize dependencies and coupling
19+
- Use modern C# features appropriately
20+
- Use repository pattern utilizing Dapper at the Repo layer for database communication for SQL Server and Postgresql
21+
22+
## Code Organization:
23+
24+
- Use meaningful names:
25+
```csharp
26+
// Good: Clear intent
27+
public async Task<Result<Order>> ProcessOrderAsync(OrderRequest request, CancellationToken cancellationToken)
28+
29+
// Avoid: Unclear abbreviations
30+
public async Task<Result<T>> ProcAsync<T>(ReqDto r, CancellationToken ct)
31+
```
32+
- Separate state from behavior:
33+
```csharp
34+
// Good: Behavior separate from state
35+
public sealed record Order(OrderId Id, List<OrderLine> Lines);
36+
37+
public static class OrderOperations
38+
{
39+
public static decimal CalculateTotal(Order order) =>
40+
order.Lines.Sum(line => line.Price * line.Quantity);
41+
}
42+
```
43+
- Prefer pure methods:
44+
```csharp
45+
// Good: Pure function
46+
public static decimal CalculateTotalPrice(
47+
IEnumerable<OrderLine> lines,
48+
decimal taxRate) =>
49+
lines.Sum(line => line.Price * line.Quantity) * (1 + taxRate);
50+
51+
// Avoid: Method with side effects
52+
public void CalculateAndUpdateTotalPrice()
53+
{
54+
this.Total = this.Lines.Sum(l => l.Price * l.Quantity);
55+
this.UpdateDatabase();
56+
}
57+
```
58+
- Use extension methods appropriately:
59+
```csharp
60+
// Good: Extension method for domain-specific operations
61+
public static class OrderExtensions
62+
{
63+
public static bool CanBeFulfilled(this Order order, Inventory inventory) =>
64+
order.Lines.All(line => inventory.HasStock(line.ProductId, line.Quantity));
65+
}
66+
```
67+
- Design for testability:
68+
```csharp
69+
// Good: Easy to test pure functions
70+
public static class PriceCalculator
71+
{
72+
public static decimal CalculateDiscount(
73+
decimal price,
74+
int quantity,
75+
CustomerTier tier) =>
76+
// Pure calculation
77+
}
78+
79+
// Avoid: Hard to test due to hidden dependencies
80+
public decimal CalculateDiscount()
81+
{
82+
var user = _userService.GetCurrentUser(); // Hidden dependency
83+
var settings = _configService.GetSettings(); // Hidden dependency
84+
// Calculation
85+
}
86+
```
87+
88+
## Dependency Management:
89+
90+
- Minimize constructor injection:
91+
```csharp
92+
// Good: Minimal dependencies
93+
public sealed class OrderProcessor(IOrderRepository repository)
94+
{
95+
// Implementation
96+
}
97+
98+
// Avoid: Too many dependencies
99+
// Too many dependencies indicates possible design issues
100+
public class OrderProcessor(
101+
IOrderRepository repository,
102+
ILogger logger,
103+
IEmailService emailService,
104+
IMetrics metrics,
105+
IValidator validator)
106+
{
107+
// Implementation
108+
}
109+
```
110+
- Prefer composition with interfaces:
111+
```csharp
112+
// Good: Composition with interfaces
113+
public sealed class EnhancedLogger(ILogger baseLogger, IMetrics metrics) : ILogger
114+
{
115+
}
116+
```

Core/Resgrid.Localization/Areas/User/Department/Department.en.resx

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,51 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
121+
<value>Request deletion of your department. This is a permanent and non-reversable operation that takes 25 days to complete and needs to run after hours. During the wait period you can cancel the request if you choose.</value>
122+
</data>
123+
<data name="RequestDepartmentDeletion" xml:space="preserve">
124+
<value>Request Department Deletion</value>
125+
</data>
126+
<data name="DeleteDepartmentCurrentlyPendingInfo" xml:space="preserve">
127+
<value>Your department has a currently pending deletion request. If you want this request to proceed there is nothing you need to do after the timestamp below (during our nightly process) your department and all of it’s data will be removed. If you wish to cancel the request and not delete the department press the “Cancel Department Deletion” button below. Please note, any changes to admins and owners will cause the process to not complete, it’s recommended that you only use the system in a read only mode to download data you wish to save.</value>
128+
</data>
129+
<data name="MappingSettingsHeader" xml:space="preserve">
130+
<value>Mapping Settings</value>
131+
</data>
132+
<data name="SavedMappingSettings" xml:space="preserve">
133+
<value>Successfully saved Mapping Settings.</value>
134+
</data>
135+
<data name="MappingSettingsPersonnelHeader" xml:space="preserve">
136+
<value>Personnel Mapping Settings</value>
137+
</data>
138+
<data name="MappingSettingsUnitsHeader" xml:space="preserve">
139+
<value>Units Mapping Settings</value>
140+
</data>
141+
<data name="MappingSettingsPersonnelAllowOverwriteLabel" xml:space="preserve">
142+
<value>Allow Status with No Location Data to hide previous location</value>
143+
</data>
144+
<data name="MappingSettingsPersonnelTTLLabel" xml:space="preserve">
145+
<value>TTL In Minutes for Personnel Locations</value>
146+
</data>
147+
<data name="MappingSettingsUnitAllowOverwriteLabel" xml:space="preserve">
148+
<value>Allow Unit Status with No Location Data to hide previous location</value>
149+
</data>
150+
<data name="MappingSettingsUnitTTLLabel" xml:space="preserve">
151+
<value>TTL In Minutes for Unit Locations</value>
152+
</data>
153+
<data name="PersonnelAllowOverwriteHelp" xml:space="preserve">
154+
<value>If enabled and a status comes in for that user (i.e. Standing By) without a geolocation it'll hide the users location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
155+
</data>
156+
<data name="UnitAllowOverwriteHelp" xml:space="preserve">
157+
<value>If enabled and a status comes in for that unit (i.e. In Quarters) without a geolocation it'll hide the units location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
158+
</data>
159+
<data name="PersonnelTTLHelp" xml:space="preserve">
160+
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a person would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
161+
</data>
162+
<data name="UnitTTLHelp" xml:space="preserve">
163+
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a unit would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
164+
</data>
120165
<data name="AccountOwner" xml:space="preserve">
121166
<value>Account Owner</value>
122167
</data>
@@ -375,15 +420,6 @@
375420
<data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
376421
<value>Delete Your Department</value>
377422
</data>
378-
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
379-
<value>Request deletion of your department. This is a permanent and non-reversable operation that takes 25 days to complete and needs to run after hours. During the wait period you can cancel the request if you choose.</value>
380-
</data>
381-
<data name="RequestDepartmentDeletion" xml:space="preserve">
382-
<value>Request Department Deletion</value>
383-
</data>
384-
<data name="DeleteDepartmentCurrentlyPendingInfo" xml:space="preserve">
385-
<value>Your department has a currently pending deletion request. If you want this request to proceed there is nothing you need to do after the timestamp below (during our nightly process) your department and all of it’s data will be removed. If you wish to cancel the request and not delete the department press the “Cancel Department Deletion” button below. Please note, any changes to admins and owners will cause the process to not complete, it’s recommended that you only use the system in a read only mode to download data you wish to save.</value>
386-
</data>
387423
<data name="EnableSupressStaffings" xml:space="preserve">
388424
<value>Enable Staffing Supress</value>
389425
</data>
@@ -393,42 +429,6 @@
393429
<data name="SupressStaffingsInfo" xml:space="preserve">
394430
<value>Select the Personnel Staffing Levels below that will be prevented from receiving any notifications, dispatches, alerts, messages, or any other communication. Most commonly these are your "Off Duty" or "On Leave" staffing levels.</value>
395431
</data>
396-
<data name="MappingSettingsHeader" xml:space="preserve">
397-
<value>Mapping Settings</value>
398-
</data>
399-
<data name="SavedMappingSettings" xml:space="preserve">
400-
<value>Successfully saved Mapping Settings.</value>
401-
</data>
402-
<data name="MappingSettingsPersonnelHeader" xml:space="preserve">
403-
<value>Personnel Mapping Settings</value>
404-
</data>
405-
<data name="MappingSettingsUnitsHeader" xml:space="preserve">
406-
<value>Units Mapping Settings</value>
407-
</data>
408-
<data name="MappingSettingsPersonnelAllowOverwriteLabel" xml:space="preserve">
409-
<value>Allow Status with No Location Data to hide previous location</value>
410-
</data>
411-
<data name="MappingSettingsPersonnelTTLLabel" xml:space="preserve">
412-
<value>TTL In Minutes for Personnel Locations</value>
413-
</data>
414-
<data name="MappingSettingsUnitAllowOverwriteLabel" xml:space="preserve">
415-
<value>Allow Unit Status with No Location Data to hide previous location</value>
416-
</data>
417-
<data name="MappingSettingsUnitTTLLabel" xml:space="preserve">
418-
<value>TTL In Minutes for Unit Locations</value>
419-
</data>
420-
<data name="PersonnelAllowOverwriteHelp" xml:space="preserve">
421-
<value>If enabled and a status comes in for that user (i.e. Standing By) without a geolocation it'll hide the users location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
422-
</data>
423-
<data name="UnitAllowOverwriteHelp" xml:space="preserve">
424-
<value>If enabled and a status comes in for that unit (i.e. In Quarters) without a geolocation it'll hide the units location on the map. Otherwise the last location of the user will be shown even if it's older.</value>
425-
</data>
426-
<data name="PersonnelTTLHelp" xml:space="preserve">
427-
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a person would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
428-
</data>
429-
<data name="UnitTTLHelp" xml:space="preserve">
430-
<value>In Minutes, how long locations are valid for to be shown in the map. I.e. a value of 60 would mean a marker for a unit would show on the maps for up to 60 minutes, afterwards would not be shown. Setting 0 disables TTL and a location, no matter how old, will be shown on the map.</value>
431-
</data>
432432
<data name="AddContact" xml:space="preserve">
433433
<value>Add Contact</value>
434434
</data>
@@ -477,4 +477,16 @@
477477
<data name="SavedModuleSettings" xml:space="preserve">
478478
<value>Department Module Settings Have Been Saved</value>
479479
</data>
480+
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
481+
<value>Group Dispatch Settings</value>
482+
</data>
483+
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
484+
<value>Unit Dispatch Settings</value>
485+
</data>
486+
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
487+
<value>Also Dispatch To Assigned Personnel</value>
488+
</data>
489+
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
490+
<value>Also Dispatch To Entire Group</value>
491+
</data>
480492
</root>

Core/Resgrid.Localization/Areas/User/Department/Department.es.resx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
121+
<value />
122+
</data>
120123
<data name="AccountOwner" xml:space="preserve">
121124
<value>Propietario de la cuenta</value>
122125
</data>
@@ -375,7 +378,16 @@
375378
<data name="DeleteDepartmentSettingsHeader" xml:space="preserve">
376379
<value />
377380
</data>
378-
<data name="DeleteDepartmentSettingsInfo" xml:space="preserve">
381+
<data name="GroupDispatchSettingsHeader" xml:space="preserve">
382+
<value />
383+
</data>
384+
<data name="UnitDispatchSettingsHeader" xml:space="preserve">
385+
<value />
386+
</data>
387+
<data name="UnitDispatchAlsoDispatchToAssignedPersonnelLabel" xml:space="preserve">
388+
<value />
389+
</data>
390+
<data name="UnitDispatchAlsoDispatchToGroupLabel" xml:space="preserve">
379391
<value />
380392
</data>
381393
</root>

0 commit comments

Comments
 (0)