public async Task <IActionResult> AddScheduledShiftAssignment(int scheduledShiftId, int?userId)
        {
            var now = _clock.UtcNow.UtcDateTime;
            //ensure the shift exists and that the user is allowed to modify it
            var shift = await _shiftRepository.GetScheduledShift(scheduledShiftId);

            if (User.RoleInPatrol(shift.PatrolId).CanMaintainSchedule() &&
                now < shift.StartsAt)
            {
                //ensure if the user is specified they are in the patrol
                PatrolUser patrolUser = null;
                if (userId.HasValue)
                {
                    patrolUser = await _patrolRepository.GetPatrolUser(userId.Value, shift.PatrolId);
                }
                if (!userId.HasValue || patrolUser != null)
                {
                    var assignment = await _scheduleService.AddScheduledShiftAssignment(scheduledShiftId, userId);

                    var scheduledShift = await _shiftRepository.GetScheduledShiftAssignments(shift.PatrolId, scheduledShiftId : scheduledShiftId);

                    return(MapScheduledShiftAssessments(scheduledShift));
                }
                else
                {
                    return(Forbid());
                }
            }
            else
            {
                return(Forbid());
            }
        }