package managedbean.common;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;

/***
 * 
 * @author Marcos García Núñez (mgarcianun@uoc.edu)
 *
 */
@Named("home")
@RequestScoped
public class homeMBean implements Serializable {

	private static final long serialVersionUID = 1L;
	private boolean isLogedIn;
	private int refresh;

	@PostConstruct
	public void init() {
		isLogedIn = SessionUtils.isLogedIn();
	}

	public List<Theme> getThemes() {
		return ThemeService.THEMES;
	}

	public boolean isLogedIn() {
		return this.isLogedIn;
	}

	public String getUserName() {
		if (this.isLogedIn == false)
			return "Invitado";
		else
			return SessionUtils.getUserName();
	}

	public String getUserId() {
		return SessionUtils.getUserId();
	}

	public int getRefresh() {
		return refresh;
	}

	public void setRefresh(int refresh) {
		this.refresh = refresh;
	}

}
