import IPhoto from "../interfaces/IPhoto";
import IPhotoDto from "../interfaces/IPhotoDto";
import IResponse from "../interfaces/IResponse";
import { MongooseDB, mongooseDB } from "../repository/mongooseDB";


export class PhotosService {
    private repository: MongooseDB
    constructor(){
        this.repository = mongooseDB
    }

    public getAllPhotos = async(): Promise<IResponse<IPhoto[] | null>> => {
        return await this.repository.getAllPhotos()
    }

    public deletePhotoById = async (id: string, user: string): Promise<IResponse<IPhoto | null>> => {
        return await this.repository.deletePhotoById(id, user)
    }

    public getPhotosByUserId = async(id: string): Promise<IResponse<IPhoto[] | null>> => {
        return await this.repository.getPhotosByUserId(id)
    }

    public addPhoto = async(photoDto: IPhotoDto): Promise<IResponse<IPhoto | null>> => {
        return await this.repository.addPhoto(photoDto)
    }
}

export const photosService = new PhotosService()