Skip to content

Commit b1f8534

Browse files
committed
RE1-T111 PR#315 fixes
1 parent 0cc55cb commit b1f8534

4 files changed

Lines changed: 38 additions & 20 deletions

File tree

Core/Resgrid.Services/CommunicationService.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,15 @@ public async Task<bool> SendCancelCallAsync(Call call, CallDispatch dispatch, st
408408
{
409409
if (profile == null || profile.MobileNumberVerified.IsContactMethodAllowedForSending())
410410
{
411-
var payment = await _subscriptionsService.GetCurrentPaymentForDepartmentAsync(departmentId);
412-
await _smsService.SendCancelCallAsync(call, dispatch, departmentNumber, departmentId, profile, call.Address, payment);
411+
try
412+
{
413+
var payment = await _subscriptionsService.GetCurrentPaymentForDepartmentAsync(departmentId);
414+
await _smsService.SendCancelCallAsync(call, dispatch, departmentNumber, departmentId, profile, call.Address, payment);
415+
}
416+
catch (Exception ex)
417+
{
418+
Logging.LogException(ex);
419+
}
413420
}
414421
}
415422

@@ -418,7 +425,14 @@ public async Task<bool> SendCancelCallAsync(Call call, CallDispatch dispatch, st
418425
{
419426
if (profile == null || profile.EmailVerified.IsContactMethodAllowedForSending())
420427
{
421-
await _emailService.SendCancelCallAsync(call, dispatch, profile);
428+
try
429+
{
430+
await _emailService.SendCancelCallAsync(call, dispatch, profile);
431+
}
432+
catch (Exception ex)
433+
{
434+
Logging.LogException(ex);
435+
}
422436
}
423437
}
424438

Web/Resgrid.Web.Services/Controllers/v4/CommunicationTestsController.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,22 @@ public async Task<StandardApiResponseV4Base> Delete(string id, CancellationToken
271271
return result;
272272
}
273273

274+
var beforeJson = test.CloneJsonToString();
275+
276+
await _communicationTestService.DeleteTestAsync(testId, cancellationToken);
277+
274278
_eventAggregator.SendMessage<AuditEvent>(new AuditEvent
275279
{
276280
DepartmentId = DepartmentId,
277281
UserId = UserId,
278282
Type = AuditLogTypes.CommunicationTestDeleted,
279-
Before = test.CloneJsonToString(),
283+
Before = beforeJson,
280284
Successful = true,
281285
IpAddress = IpAddressHelper.GetRequestIP(Request, true),
282286
ServerName = Environment.MachineName,
283287
UserAgent = $"{Request.Headers["User-Agent"]} {Request.Headers["Accept-Language"]}"
284288
});
285289

286-
await _communicationTestService.DeleteTestAsync(testId, cancellationToken);
287-
288290
result.Status = ResponseHelper.Deleted;
289291
ResponseHelper.PopulateV4ResponseData(result);
290292

Web/Resgrid.Web/Areas/User/Controllers/CommunicationTestController.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,22 @@ public async Task<IActionResult> Delete(string testId, CancellationToken cancell
216216
if (test == null || test.DepartmentId != DepartmentId)
217217
return Unauthorized();
218218

219+
var beforeJson = test.CloneJsonToString();
220+
221+
await _communicationTestService.DeleteTestAsync(id, cancellationToken);
222+
219223
_eventAggregator.SendMessage<AuditEvent>(new AuditEvent
220224
{
221225
DepartmentId = DepartmentId,
222226
UserId = UserId,
223227
Type = AuditLogTypes.CommunicationTestDeleted,
224-
Before = test.CloneJsonToString(),
228+
Before = beforeJson,
225229
Successful = true,
226230
IpAddress = IpAddressHelper.GetRequestIP(Request, true),
227231
ServerName = Environment.MachineName,
228232
UserAgent = $"{Request.Headers["User-Agent"]} {Request.Headers["Accept-Language"]}"
229233
});
230234

231-
await _communicationTestService.DeleteTestAsync(id, cancellationToken);
232-
233235
return RedirectToAction("Index");
234236
}
235237

Web/Resgrid.Web/Areas/User/Controllers/DispatchController.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,10 @@ public async Task<IActionResult> UpdateCall(UpdateCallView model, IFormCollectio
641641
call.IndoorMapFloorId = null;
642642
}
643643

644-
List<CallDispatch> existingDispatches = new List<CallDispatch>(call.Dispatches);
645-
List<CallDispatchGroup> existingGroupDispatches = new List<CallDispatchGroup>(call.GroupDispatches);
646-
List<CallDispatchUnit> existingUnitDispatches = new List<CallDispatchUnit>(call.UnitDispatches);
647-
List<CallDispatchRole> existingRoleDispatches = new List<CallDispatchRole>(call.RoleDispatches);
644+
List<CallDispatch> existingDispatches = new List<CallDispatch>(call.Dispatches ?? Enumerable.Empty<CallDispatch>());
645+
List<CallDispatchGroup> existingGroupDispatches = new List<CallDispatchGroup>(call.GroupDispatches ?? Enumerable.Empty<CallDispatchGroup>());
646+
List<CallDispatchUnit> existingUnitDispatches = new List<CallDispatchUnit>(call.UnitDispatches ?? Enumerable.Empty<CallDispatchUnit>());
647+
List<CallDispatchRole> existingRoleDispatches = new List<CallDispatchRole>(call.RoleDispatches ?? Enumerable.Empty<CallDispatchRole>());
648648

649649
List<string> dispatchingUserIds = new List<string>();
650650
List<int> dispatchingGroupIds = new List<int>();
@@ -893,10 +893,10 @@ public async Task<IActionResult> UpdateCall(UpdateCallView model, IFormCollectio
893893
// Send cancel notifications to removed entities
894894
if (model.NotifyCancelledEntities)
895895
{
896-
var savedUserIds = new HashSet<string>(call.Dispatches.Select(x => x.UserId));
897-
var savedGroupIds = new HashSet<int>(call.GroupDispatches.Select(x => x.DepartmentGroupId));
898-
var savedUnitIds = new HashSet<int>(call.UnitDispatches.Select(x => x.UnitId));
899-
var savedRoleIds = new HashSet<int>(call.RoleDispatches.Select(x => x.RoleId));
896+
var savedUserIds = new HashSet<string>((call.Dispatches ?? Enumerable.Empty<CallDispatch>()).Select(x => x.UserId));
897+
var savedGroupIds = new HashSet<int>((call.GroupDispatches ?? Enumerable.Empty<CallDispatchGroup>()).Select(x => x.DepartmentGroupId));
898+
var savedUnitIds = new HashSet<int>((call.UnitDispatches ?? Enumerable.Empty<CallDispatchUnit>()).Select(x => x.UnitId));
899+
var savedRoleIds = new HashSet<int>((call.RoleDispatches ?? Enumerable.Empty<CallDispatchRole>()).Select(x => x.RoleId));
900900

901901
var cancelledUserIds = existingDispatches.Select(x => x.UserId)
902902
.Where(y => !savedUserIds.Contains(y)).ToList();
@@ -912,13 +912,13 @@ public async Task<IActionResult> UpdateCall(UpdateCallView model, IFormCollectio
912912
var departmentNumber = await _departmentSettingsService.GetTextToCallNumberForDepartmentAsync(DepartmentId);
913913

914914
// Build set of still-dispatched user IDs for dedup
915-
var stillDispatchedUserIds = new HashSet<string>(call.Dispatches.Select(x => x.UserId));
916-
foreach (var gd in call.GroupDispatches)
915+
var stillDispatchedUserIds = new HashSet<string>((call.Dispatches ?? Enumerable.Empty<CallDispatch>()).Select(x => x.UserId));
916+
foreach (var gd in call.GroupDispatches ?? Enumerable.Empty<CallDispatchGroup>())
917917
{
918918
var members = await _departmentGroupsService.GetAllMembersForGroupAsync(gd.DepartmentGroupId);
919919
foreach (var m in members) stillDispatchedUserIds.Add(m.UserId);
920920
}
921-
foreach (var rd in call.RoleDispatches)
921+
foreach (var rd in call.RoleDispatches ?? Enumerable.Empty<CallDispatchRole>())
922922
{
923923
var members = await _personnelRolesService.GetAllMembersOfRoleAsync(rd.RoleId);
924924
foreach (var m in members) stillDispatchedUserIds.Add(m.UserId);

0 commit comments

Comments
 (0)