mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
|
import { isHttpResponse } from 'src/app/services/http.service';
|
|
import { RoomByIdInputDTO } from '../../data/dto/room/roomByIdInputDTO';
|
|
import { RoomRemoteDataSourceService } from '../../data/repository/room-remote-repository.service';
|
|
import { RoomLocalRepository } from '../../data/repository/room-local-repository.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class DeleteRoomUseCaseService {
|
|
|
|
constructor(
|
|
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
|
// private roomMemoryDataSourceService: Store<RoomRemoteDataSourceState>,
|
|
private roomLocalDataSourceService: RoomLocalRepository,
|
|
) { }
|
|
|
|
|
|
@captureAndReraiseAsync('RoomRepositoryService/deleteRoomById')
|
|
async execute(id: RoomByIdInputDTO) {
|
|
const result = await this.roomRemoteDataSourceService.deleteRoom(id)
|
|
|
|
if(result.isOk()) {
|
|
|
|
const result = await this.roomLocalDataSourceService.deleteRoomById(id)
|
|
// this.messageLiveDataSourceService.sendMessage({
|
|
// type: 'createRoom',
|
|
// payload: {a: '5'}
|
|
// })
|
|
|
|
return result
|
|
} else if (isHttpResponse(result.error)) {
|
|
if(result.error.status == 404) {
|
|
await this.roomLocalDataSourceService.deleteRoomById(id)
|
|
}
|
|
// this.httpErrorHandle.httpStatusHandle(result.error)
|
|
}
|
|
|
|
return result
|
|
}
|
|
}
|