/*
 * 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 session;

import entities.DiscountCode;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Hoss
 */
@Stateless
@LocalBean
public class DiscountCodeManager {
        @PersistenceContext(unitName = "CustomerApp-ejbPU")
        private EntityManager em;
        
        public List<DiscountCode> getDiscountCodes() {
        Query query = em.createNamedQuery("DiscountCode.findAll");
        return query.getResultList();
        }

        public void persist(DiscountCode dc) {
        em.persist(dc);
        }
}
