-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added session registrations service + refactor B.E. #78
- Loading branch information
rbento1096
committed
Feb 20, 2024
1 parent
5a3bdda
commit 873ee07
Showing
3 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
front-end/src/app/tabs/sessionRegistrations/sessionRegistrations.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { IDEAApiService } from '@idea-ionic/common'; | ||
|
||
import { SessionRegistration } from '@models/sessionRegistration.model'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class SessionRegistrationsService { | ||
constructor(private api: IDEAApiService) {} | ||
|
||
/** | ||
* Get the list of registrations for the user or session. | ||
*/ | ||
async getList(sessionId?: string): Promise<SessionRegistration[]> { | ||
return (await this.api.getResource(['registrations'], { params: { sessionId } })).map( | ||
sr => new SessionRegistration(sr) | ||
); | ||
} | ||
|
||
/** | ||
* Get the full details of a registration by its id. | ||
*/ | ||
async getById(sessionId: string): Promise<SessionRegistration> { | ||
return new SessionRegistration(await this.api.getResource(['registrations', sessionId])); | ||
} | ||
|
||
/** | ||
* Insert a new registration. | ||
*/ | ||
async insert(sessionId: string): Promise<SessionRegistration> { | ||
return new SessionRegistration(await this.api.postResource(['registrations', sessionId])); | ||
} | ||
/** | ||
* Delete a registration. | ||
*/ | ||
async delete(registration: SessionRegistration): Promise<void> { | ||
await this.api.deleteResource(['registrations', registration.sessionId]); | ||
} | ||
} |