add either pattern

This commit is contained in:
Peter Maquiran
2024-05-30 12:03:30 +01:00
parent 3c4ec1a432
commit 746db6f583
9 changed files with 410 additions and 85 deletions
@@ -11,6 +11,7 @@ import { EventListToApproveMapper } from './mapper/eventToApproveListMapper';
import { err, ok } from 'neverthrow';
import { of } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { EventToApproveDetailsMapper } from './mapper/EventToApproveDetailsMapper';
@Injectable({
providedIn: 'root'
@@ -22,20 +23,45 @@ export class AgendaDataRepositoryService {
private utils: Utils
) { }
getEventById(id: string) {
return this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventMapper.toDomain(response.data)
})
)
async getEventById(id: string) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventMapper.toDomain(response.data)
})
).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) {
return this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
}
))
async getEventToApproveById(id: string) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventToApproveDetailsMapper.toDomain(response.data)
})
).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
async EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
}
)).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
eventToApproveList({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) {