def execute(
        self, dto: EditBoardDto
    ) -> Union[UseCaseSuccessOutput, UseCaseFailureOutput]:
        try:
            board: Board = self.board_repo.get_board(board_id=dto.board_id)

            if board.user_id != dto.user_id:
                return UseCaseFailureOutput(NotFoundException())

            board: Board = self.board_repo.edit_board(dto=dto)

            return UseCaseSuccessOutput(value=board)
        except NotFoundException:
            return UseCaseFailureOutput(NotFoundException())
Beispiel #2
0
    def get_board(self, board_id: int = None) -> Board:
        bm = aliased(BoardModels)
        board = session.query(bm).filter(bm.id == board_id).first()

        if not board:
            raise NotFoundException()
        return board.to_entity()
 async def find_apartment_ad(apartment_ad_id: str) -> ApartmentAd:
     optional_apartment_ad = apartment_ads_service.find_apartment_ad(apartment_ad_id)
     if optional_apartment_ad is None:
         logger.info(f'Apartment ad was not found for id: {apartment_ad_id}')
         raise NotFoundException()
     return optional_apartment_ad
Beispiel #4
0
 def get_user(self, username: str = None) -> UserModels:
     user = session.query(UserModels).filter_by(username=username).first()
     if not user:
         raise NotFoundException()
     return user.to_entity()
 async def find_location_deep(location_id: str) -> LocationDTO:
     deep_location = locations_service.find_location_deep(location_id)
     if deep_location is None:
         raise NotFoundException()
     return LocationDTO.from_location(deep_location)
 async def find_location_nested(location_id: str) -> LocationDTO:
     nested_location = locations_service.find_location_nested(location_id)
     if nested_location is None:
         raise NotFoundException()
     return LocationDTO.from_location(nested_location)