package de.jottyfan.camporganizer.module.confirmation.person;

import java.util.ArrayList;
import java.util.List;

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

import de.jottyfan.camporganizer.db.jooq.enums.EnumProgress;
import de.jottyfan.camporganizer.module.confirmation.person.model.CampBean;
import de.jottyfan.camporganizer.module.confirmation.person.model.PersonBean;

/**
 *
 * @author jotty
 *
 */
@Service
public class PersonService {
	@Autowired
	private PersonRepository gateway;

	public PersonBean getPerson(String username, Integer pk) {
		return gateway.getPerson(username, pk);
	}

	public Integer updatePerson(PersonBean bean, String worker) {
		return gateway.updatePerson(bean, worker);
	}

	public List<CampBean> getCamps(String username) {
		return gateway.getCamps(username);
	}

	public String getAnnotations(Integer pk) {
		return gateway.getAnnotations(pk);
	}

	/**
	 * get the price of the camp
	 *
	 * @param pk the ID of the person, not the camp
	 * @return the camp price
	 */
	public String getCampPrice(Integer pk) {
		return gateway.getCampprice(pk);
	}

	public List<String> getProgresses() {
		List<String> list = new ArrayList<>();
		for (EnumProgress p : EnumProgress.values()) {
			list.add(p.getLiteral());
		}
		return list;
	}
}
