Skip to content
Merged
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
43 changes: 23 additions & 20 deletions Core/Resgrid.Services/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,26 +450,29 @@ public async Task<DepartmentGroup> GetGroupForEventAsync(ProcessedNotification n
//NotificationItem dynamicData = (NotificationItem)JsonConvert.DeserializeObject(data);
NotificationItem dynamicData = ObjectSerialization.Deserialize<NotificationItem>(notification.Data);

if (notification.Type == EventTypes.UnitStatusChanged)
if (dynamicData != null)
{
var unitEvent = await _unitsService.GetUnitStateByIdAsync(dynamicData.StateId);
return await _departmentGroupsService.GetGroupByIdAsync(unitEvent.Unit.StationGroupId.GetValueOrDefault());
}
else if (notification.Type == EventTypes.PersonnelStatusChanged)
{
var userStaffing = await _userStateService.GetUserStateByIdAsync(dynamicData.StateId);
var group = await _departmentGroupsService.GetGroupForUserAsync(userStaffing.UserId, notification.DepartmentId);
return group;
}
else if (notification.Type == EventTypes.PersonnelStatusChanged)
{
var actionLog = await _actionLogsService.GetActionLogByIdAsync(dynamicData.StateId);
var group = await _departmentGroupsService.GetGroupForUserAsync(actionLog.UserId, notification.DepartmentId);
return group;
}
else if (notification.Type == EventTypes.UserAssignedToGroup)
{
return await _departmentGroupsService.GetGroupByIdAsync(dynamicData.GroupId);
if (notification.Type == EventTypes.UnitStatusChanged)
{
var unitEvent = await _unitsService.GetUnitStateByIdAsync(dynamicData.StateId);
return await _departmentGroupsService.GetGroupByIdAsync(unitEvent.Unit.StationGroupId.GetValueOrDefault());
}
else if (notification.Type == EventTypes.PersonnelStatusChanged)
{
var userStaffing = await _userStateService.GetUserStateByIdAsync(dynamicData.StateId);
var group = await _departmentGroupsService.GetGroupForUserAsync(userStaffing.UserId, notification.DepartmentId);
return group;
}
else if (notification.Type == EventTypes.PersonnelStatusChanged)
{
var actionLog = await _actionLogsService.GetActionLogByIdAsync(dynamicData.StateId);
var group = await _departmentGroupsService.GetGroupForUserAsync(actionLog.UserId, notification.DepartmentId);
return group;
}
else if (notification.Type == EventTypes.UserAssignedToGroup)
{
return await _departmentGroupsService.GetGroupByIdAsync(dynamicData.GroupId);
}
}

return null;
Expand Down Expand Up @@ -953,7 +956,7 @@ public async Task<string> GetMessageForTypeAsync(ProcessedNotification notificat

public async Task<bool> DeleteDepartmentNotificationByIdAsync(int notificationId, CancellationToken cancellationToken = default(CancellationToken))
{
var notification = await
var notification = await
_departmentNotificationRepository.GetByIdAsync(notificationId);

if (notification != null)
Expand Down
Loading