public async Task <IActionResult> RemoveParticipant(int participantId) { // Get participant Participant participant = await _shiftService.GetParticipant(participantId); if (participant == null) { return(BadRequest()); } // User has access to shift? string userId = _userManager.GetUserId(User); if (!(await _userService.HasShiftAccess(userId, participant.ShiftId))) { return(BadRequest()); } // If member is not self, is there permission to remove? if (participant.Member.UserId != userId && !participant.Member.Group.UsersCanScheduleOthers) { return(BadRequest()); } await _shiftService.RemoveParticipant(participantId); return(Ok()); }