public List <Commande> GetCommande(int idclient)
        {
            try
            {
                String sql = "sp_GetCommande";

                //Creation du table de paratre SQL pour le mettre dans GetDataReader
                List <SqlParameter> sqlParameters = new List <SqlParameter>();

                //Creation d'un parametre SQL et ajout dans le tableau precedemment créé
                sqlParameters.Add(new SqlParameter("@IdClient", idclient));

                List <Commande> ListeDesCommandes = new List <Commande>();
                base.GetDataReader(sql, sqlParameters);
                if (base.sqlDataReader.HasRows)
                {
                    while (base.sqlDataReader.Read())
                    {
                        int      IdReservation = Convert.ToInt32(base.sqlDataReader["IdReservation"]);
                        Client   Locataire     = null;
                        DateTime DateDebut     = Convert.ToDateTime(base.sqlDataReader["DateDebut"]);
                        DateTime DateFin       = Convert.ToDateTime(base.sqlDataReader["DateFin"]);
                        string   PrixTotal     = Convert.ToString(base.sqlDataReader["PrixTotal"]);
                        bool     Statut        = Convert.ToBoolean(base.sqlDataReader["Statut"]);
                        int      ModePaiement  = Convert.ToInt32(base.sqlDataReader["IdPaiement"]);

                        Hebergement Location = new Hebergement();
                        Location.IdHebergement = Convert.ToInt32(base.sqlDataReader["IdHebergement"]);
                        Location.Nom           = Convert.ToString(base.sqlDataReader["Nom"]);
                        Location.Photo         = Constants.CheminPhoto + Convert.ToString(base.sqlDataReader["NomPhoto"]);
                        Location.Nom           = Convert.ToString(base.sqlDataReader["Nom"]);
                        Location.Type          = Convert.ToString(base.sqlDataReader["NomHebergement"]);
                        Location.Description   = Convert.ToString(base.sqlDataReader["Description"]);
                        DaoClient daoclient = new DaoClient();
                        Location.Proprietaire = daoclient.GetUtilisateurId(Convert.ToInt32(base.sqlDataReader["IdProprietaire"]));
                        Commande maCommande = new Commande(IdReservation, Locataire, Location, DateDebut, DateFin, PrixTotal, Statut, ModePaiement);
                        ListeDesCommandes.Add(maCommande);
                    }
                }
                return(ListeDesCommandes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        /// <summary>
        /// Genere une liste d'avis concernant UN Hebergement
        /// </summary>
        /// <returns>Retourne une Liste d'Avis Concernant un hebergement</returns>
        public List <Avis> GetAvisHebergement(int IdHebergement)
        {
            List <Avis> ListeAvis = null;

            try
            {
                // requete + parametres à transmettre.
                string sql = "sp_GetAvisHebergement";
                List <SqlParameter> sqlParameters = new List <SqlParameter>();
                sqlParameters.Add((new SqlParameter("@IdHebergement", IdHebergement)));

                //Execution de GetDataReader Erité de DataAccess
                base.GetDataReader(sql, sqlParameters);
                //Verification de recuperation de données
                ListeAvis = new List <Avis>();
                if (base.sqlDataReader.HasRows)
                {
                    while (base.sqlDataReader.Read())
                    {
                        Avis avis = new Avis();
                        avis.Date        = Convert.ToDateTime(base.sqlDataReader["Date"]);
                        avis.Commentaire = Convert.ToString(base.sqlDataReader["Commentaire"]);
                        avis.Note        = Convert.ToInt32(base.sqlDataReader["Note"]);
                        avis.Statut      = Convert.ToBoolean(base.sqlDataReader["Statut"]);

                        avis.IdClient = Convert.ToInt32(base.sqlDataReader["IdClient"]);
                        DaoClient daoClient = new DaoClient();
                        avis.Client = daoClient.GetUtilisateurId(Convert.ToInt32(base.sqlDataReader["IdClient"]));

                        avis.IdHebergement = Convert.ToInt32(base.sqlDataReader["IdHebergement"]);
                        DaoHebergement daoHebergement = new DaoHebergement();
                        avis.Hebergement = daoHebergement.GetHebergement(Convert.ToInt32(base.sqlDataReader["IdHebergement"]));

                        ListeAvis.Add(avis);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(ListeAvis);
        }