public List <orderHisto> getcommandehisto(ClientReturn client)
        {
            List <orderHisto> listOrderHisto = new List <orderHisto>();

            List <Commande> listCommand = dbContext.Commandes.Where(w => w.id_client == client.id_client).ToList();



            foreach (Commande com in listCommand)
            {
                orderHisto orderhisto = new orderHisto();

                Achat achat = dbContext.Achats.FirstOrDefault(f => f.id_commande == com.id_commande);

                Stock st = dbContext.Stocks.FirstOrDefault(f => f.id_stock == achat.id_stock);

                Produit pro = dbContext.Produits.FirstOrDefault(f => f.id_stock == st.id_stock);

                orderhisto.heureCommand       = com.heure_commande;
                orderhisto.statutLivraison    = com.statut_livraison;
                orderhisto.quantite           = (int)achat.quantité;
                orderhisto.prix_total         = (double)achat.prix_total;
                orderhisto.nom_Produit        = st.nom_produit_stock;
                orderhisto.prix_Produit_Unite = (double)pro.prix_unite;
                listOrderHisto.Add(orderhisto);
            }

            return(listOrderHisto);
        }
        public ClientReturn recupereParEmail(string email)
        {
            ClientReturn clinew = new ClientReturn();

            var cli = dbContext.Clients.FirstOrDefault(f => f.email == email);

            clinew.nom       = cli.nom;
            clinew.prenom    = cli.prenom;
            clinew.email     = cli.email;
            clinew.password  = cli.password;
            clinew.id_client = cli.id_client;

            return(clinew);
        }
 public string modifierClients(ClientReturn client)
 {
     try
     {
         var modif = dbContext.Clients.FirstOrDefault(f => f.id_client == client.id_client);
         modif.nom      = client.nom;
         modif.prenom   = client.prenom;
         modif.email    = client.email;
         modif.password = client.password;
         dbContext.SaveChanges();
         return("modifié !");
     }catch (Exception e)
     {
         return("Erreur !!!");
     }
 }
        public string supprimerClients(ClientReturn client)
        {
            try
            {
                var suprime      = dbContext.Clients.FirstOrDefault(f => f.id_client == client.id_client);
                var comClientSup = dbContext.Commandes.Where(f => f.id_client == suprime.id_client);
                foreach (var a in comClientSup)
                {
                    dbContext.Commandes.Remove(a);

                    var achat = dbContext.Achats.FirstOrDefault(f => f.id_commande == a.id_commande);
                    dbContext.Achats.Remove(achat);
                }

                dbContext.Clients.Remove(suprime);
                dbContext.Clients.Remove(suprime);
                dbContext.SaveChanges();
                return("utilisateur supprimé de la BDD!");
            } catch (Exception ex)
            {
                return("erreur !!");
            }
        }