package com.hepl.tunefortwo.service.impl;

import java.util.List;
import java.util.Optional;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;

import com.hepl.tunefortwo.entity.MixtureMaster;
import com.hepl.tunefortwo.repository.MixtureMasterRepository;
import com.hepl.tunefortwo.service.MixtureMasterService;
import com.hepl.tunefortwo.utils.AppMessages;

import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class MixtureMasterServiceImpl implements MixtureMasterService {
	private final MixtureMasterRepository mixtureMasterRepository;
	public MixtureMasterServiceImpl(MixtureMasterRepository mixtureMasterRepository) {
		super();
		this.mixtureMasterRepository = mixtureMasterRepository;
	}
	@Override
	public List<MixtureMaster> getmixtureMasterPrice() {

		log.info("Get all MixtureMasterType");
		return mixtureMasterRepository.findAll();
	}
	@Override
	public void setmixtureMasterById(Double price, String id) {
		MixtureMaster mixtureMaster = mixtureMasterRepository.findById(id)
				.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, AppMessages.RESOURCE_NOT_FOUND));
		mixtureMaster.setPrice(price);
		mixtureMasterRepository.save(mixtureMaster);
	}
	@Override
	public MixtureMaster getmixtureMaster(String id) {
		MixtureMaster mixtureMaster = mixtureMasterRepository.findById(id)
				.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, AppMessages.RESOURCE_NOT_FOUND));
		
		return mixtureMaster;
	}
	

}
