package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jasamedika.medifirst2000.dao.InformasiTarifLayananDao;
import com.jasamedika.medifirst2000.dao.ProdukDao;
import com.jasamedika.medifirst2000.entities.HargaNettoProdukByKelas;
import com.jasamedika.medifirst2000.entities.Produk;
import com.jasamedika.medifirst2000.service.InformasiTarifLayananService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.InformasiTarifLayananVO;

@Service("InformasiTarifLayananService")
public class InformasiTarifLayananServiceImpl implements InformasiTarifLayananService{

	@Autowired
	private InformasiTarifLayananDao informasiTarifLayananDao;
	
	@Override
	public Map<String, Object> getInformasiTarifLayananRuangan() {
		Map<String, Object> result = new HashMap<>();
		List<InformasiTarifLayananVO> list = new ArrayList<InformasiTarifLayananVO>();
		list = informasiTarifLayananDao.getInformasiTarifRuangan();
		if(CommonUtil.isNotNullOrEmpty(list)){
			result.put("data", list);
			result.put("dataFound", true);
		}
		else{
			result.put("dataFound", false);
		}
		return result;
	}

	@Override
	public Map<String, Object> getHargaByIdProduk(Integer produkId) {
		Map<String, Object> result = new HashMap<>();
		List<InformasiTarifLayananVO> list = new ArrayList<InformasiTarifLayananVO>();
		list = informasiTarifLayananDao.getInformasiHargaByIdProduk(produkId);
		if(CommonUtil.isNotNullOrEmpty(list)){
			result.put("data", list);
			result.put("dataFound", true);
		}
		else{
			result.put("dataFound", false);
		}
		return result;
	}

	@Override
	public Map<String, Object> getAllHargaProduk() {
		Map<String, Object> result = new HashMap<>();
		List<InformasiTarifLayananVO> list = new ArrayList<InformasiTarifLayananVO>();
		list = informasiTarifLayananDao.getAllInformasiHarga();
		if(CommonUtil.isNotNullOrEmpty(list)){
			result.put("data", list);
			result.put("dataFound", true);
		}
		else{
			result.put("dataFound", false);
		}
		return result;
	}

	@Override
	public Map<String, Object> getHargaNettoByNamaProduk(String namaProduk) {
		Map<String, Object> result = new HashMap<>();
		List<InformasiTarifLayananVO> list = new ArrayList<InformasiTarifLayananVO>();
		list = informasiTarifLayananDao.getInformasiHargaNettoByNamaProduk(namaProduk);
		if(CommonUtil.isNotNullOrEmpty(list)){
			result.put("data", list);
			result.put("dataFound", true);
		}
		else{
			result.put("dataFound", false);
		}
		return result;
	}

	@Override
	public Map<String, Object> getHargaProdukByIdProdukMinimized(Integer produkId) {
		Map<String, Object> result = new HashMap<>();
		List<InformasiTarifLayananVO> list = new ArrayList<InformasiTarifLayananVO>();
		list = informasiTarifLayananDao.getInformasiHargaByIdProdukMinimized(produkId);
		if(CommonUtil.isNotNullOrEmpty(list)){
			result.put("data", list);
			result.put("dataFound", true);
		}
		else{
			result.put("dataFound", false);
		}
		return result;
	}
	
	@Autowired
	private ProdukDao produkDao;
	
	@Override
	public Map<String, Object> findProdukByDetailJenisProdukAkomodasi() {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Produk> list = new ArrayList<Produk>();
		list = produkDao.findProdukByDetailJenisProdukAkomodasi();
		if(CommonUtil.isNotNullOrEmpty(list)){
			result.put("data", list);
			result.put("dataFound", true);
		}
		else{
			result.put("dataFound", false);
		}
		return result;
	}
	
}
