@@ -26,6 +26,7 @@ import type { AttendeeRepository } from "./attendee-repository"
2626
2727export interface AttendeeService {
2828 registerForEvent ( userId : string , attendanceId : string , attendancePoolId : string ) : Promise < Attendee >
29+ adminRegisterForEvent ( userId : string , attendanceId : string , attendancePoolId : string ) : Promise < Attendee >
2930 deregisterForEvent ( userId : string , attendanceId : string ) : Promise < void >
3031 adminDeregisterForEvent ( id : AttendeeId ) : Promise < void >
3132 updateSelectionResponses ( id : AttendanceId , responses : AttendanceSelectionResponse [ ] ) : Promise < Attendee >
@@ -102,6 +103,32 @@ export class AttendeeServiceImpl implements AttendeeService {
102103 return attendee
103104 }
104105
106+ async adminRegisterForEvent ( userId : UserId , attendanceId : AttendancePoolId , attendancePoolId : AttendanceId ) {
107+ const user = await this . userService . getById ( userId )
108+ const attendance = await this . attendanceRepository . getById ( attendanceId )
109+ const attendancePool = attendance . pools . find ( ( pool ) => pool . id === attendancePoolId )
110+
111+ if ( attendancePool === undefined ) {
112+ throw new AttendancePoolNotFoundError ( "Tried to register to unknown attendance pool" )
113+ }
114+
115+ const registerTime = new Date ( )
116+
117+ const attendee = await this . attendeeRepository . create ( {
118+ userId,
119+ attendancePoolId,
120+ attendanceId : attendancePool . attendanceId ,
121+
122+ displayName : ( user . firstName && user . lastName ) ?? user . email ,
123+ userGrade : user . membership ? getMembershipGrade ( user . membership ) : null ,
124+
125+ reserveTime : registerTime ,
126+ reserved : true ,
127+ } )
128+
129+ return attendee
130+ }
131+
105132 async registerForEvent ( userId : UserId , attendanceId : AttendancePoolId , attendancePoolId : AttendanceId ) {
106133 const user = await this . userService . getById ( userId )
107134 const attendance = await this . attendanceRepository . getById ( attendanceId )
0 commit comments