package com.palmnest.service.notice.impl;

import com.palmnest.dao.notice.TemplateLibraryDao;
import com.palmnest.model.estateserve.TemplateLibrary;
import com.palmnest.service.impl.GenericManagerImpl;
import com.palmnest.service.notice.TemplateLibraryManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("templateLibraryManager")
public class TemplateLibraryManagerImpl extends GenericManagerImpl<TemplateLibrary, Integer> implements TemplateLibraryManager {

	private TemplateLibraryDao templateLibraryDao;

	@Autowired
	public void setRoomInfoDao(TemplateLibraryDao templateLibraryDao) {
		this.templateLibraryDao = templateLibraryDao;
		this.dao = templateLibraryDao;
	}

	@Override
	public String saveOrUpdate(TemplateLibrary templateLibrary) {

		String isSuccess = "fail";
		if (templateLibrary.getId() == null) {
			TemplateLibrary model = templateLibraryDao.save(templateLibrary);
			if (model != null) {
				isSuccess = "success";
			}
		} else {
			try {
				templateLibraryDao.updateObj(templateLibrary);
				isSuccess = "success";
			} catch (Exception e) {

				isSuccess = "fail";
			}
		}
		return isSuccess;
	}


}
