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.RIS_OrderDao;
import com.jasamedika.medifirst2000.entities.RIS_Order;
import com.jasamedika.medifirst2000.service.RIS_OrderService;
import com.jasamedika.medifirst2000.util.CommonUtil;

@Service("RIS_OrderService")
public class RIS_OrderServiceImpl implements RIS_OrderService {

	@Autowired
	private RIS_OrderDao rIS_OrderDao;

	@Override
	public Map<String, Object> save(RIS_Order vo) {
		Map<String, Object> result = new HashMap<>();
		if(CommonUtil.isNotNullOrEmpty(vo)) {
			RIS_Order model = rIS_OrderDao.save(vo);
			result.put("id", model.getORDER_KEY());
		}
		return result;
	}

	@Override
	public void delete(RIS_Order vo) {
		if(CommonUtil.isNotNullOrEmpty(vo)) {
			rIS_OrderDao.delete(vo.getORDER_KEY());
		}
	}
	
	@Override
	public RIS_Order getOne(RIS_Order vo) {
		RIS_Order result = new RIS_Order();
		if(CommonUtil.isNotNullOrEmpty(vo.getORDER_KEY())) {
			result = rIS_OrderDao.findOne(vo.getORDER_KEY());
		}
		return result;
	}
	
	@Override
	public List<RIS_Order> getAll(){
		List<RIS_Order> result = new ArrayList<>();
		result = (List<RIS_Order>) rIS_OrderDao.findAll();
		return result;
	}
	
	@Override
	public RIS_Order getOneByNoOrder(String noRec) {
		RIS_Order result = new RIS_Order();
		if(CommonUtil.isNotNullOrEmpty(noRec)) {
			result = rIS_OrderDao.getOneByNoOrder(noRec);
		}
		return result;
	}
}
