/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package managed_beans;

import entities.Pisac;
import java.time.LocalDate;
import java.time.Period;
import java.util.List;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.annotation.FacesConfig;
import util.dao.PisacDAO;

/**
 *
 * @author jelic
 */
@Named(value = "pisciManagedBean")
@RequestScoped
@FacesConfig(version = FacesConfig.Version.JSF_2_3)
public class PisciManagedBean {

    /**
     * Creates a new instance of PisciManagedBean
     */
    public PisciManagedBean() {
    }
    
    public List<Pisac> dohvatiPisce(){
        return new PisacDAO().dohvatiSvePisce();
    }
    
    public boolean punoletan(LocalDate rodj){
        Period p = Period.between(rodj, LocalDate.now());
        return p.getYears()>18;
    }
    
    public void postaviKorisnika(String korime){
        util.SessionUtils.getSession().setAttribute("korisnik", korime);
    }
    
}
