public List <Produit> GetAllProduit() { ProduitQuery pq = new ProduitQuery(ctx); CategorieQuery cq = new CategorieQuery(ctx); List <Produit> prods = pq.GetAll().ToList(); prods.ForEach((p) => { p.Categorie = cq.GetCategorie(p.CategorieId).FirstOrDefault(); }); return(prods); }
public Produit GetProduit(int id) { ProduitQuery pq = new ProduitQuery(ctx); CategorieQuery cq = new CategorieQuery(ctx); Produit p; Categorie c; try { p = pq.GetByID(id).First(); c = cq.GetCategorie(p.CategorieId).First(); p.Categorie = c; }catch (Exception e) { throw e; } return(p); }
public List <Produit> GetProduitByLib(String lib) { ProduitQuery pq = new ProduitQuery(ctx); CategorieQuery cq = new CategorieQuery(ctx); List <Produit> prods; try { prods = pq.GetByLibelle(lib).ToList(); prods.ForEach((p) => { p.Categorie = cq.GetCategorie(p.CategorieId).FirstOrDefault(); }); }catch (Exception e) { throw e; } return(prods); }
public List <Produit> GetPreferredProduits() { ProduitQuery pc = new ProduitQuery(ctx); CategorieQuery cq = new CategorieQuery(ctx); List <Produit> prods; try { prods = pc.GetPref().ToList(); prods.ForEach((p) => { p.Categorie = cq.GetCategorie(p.CategorieId).FirstOrDefault(); }); } catch (Exception e) { throw e; } return(prods); }
public Categorie GetCategorie(int id) { CategorieQuery pq = new CategorieQuery(ctx); return(pq.GetCategorie(id).FirstOrDefault()); }