class TipsAndTricksServiceImpl implements TipsAndTricksService {

    @CacheEvict(value = CacheConstants.TIPS_AND_TRICKS_CACHE_NAME, allEntries = true)
    @Override
    public TipsAndTricksDtoResponse save(TipsAndTricksDtoRequest tipsAndTricksDtoRequest, MultipartFile image,
                                         String email) {
        TipsAndTricks toSave = modelMapper.map(tipsAndTricksDtoRequest, TipsAndTricks.class);
        toSave.setAuthor(userService.findByEmail(email));
        if (tipsAndTricksDtoRequest.getImage() != null && !tipsAndTricksDtoRequest.getImage().isEmpty()) {
            image = modelMapper.map(tipsAndTricksDtoRequest.getImage(), MultipartFile.class);
        }
        if (image != null) {
            toSave.setImagePath(fileService.upload(image).toString());
        }
        toSave.setTags(
            tagService.findTipsAndTricksTagsByNames(tipsAndTricksDtoRequest.getTags()));

        try {
            tipsAndTricksRepo.save(toSave);
        } catch (DataIntegrityViolationException e) {
            throw new NotSavedException(ErrorMessage.TIPS_AND_TRICKS_NOT_SAVED);
        }

        return modelMapper.map(toSave, TipsAndTricksDtoResponse.class);
    }

}