public int InsertPartie(PartieDTO partie)
        {
            this.con.Open();
            string     q   = "insert into partie(id_personnage,difficulte) values(" + partie.IdPersonnage + "," + partie.Difficulte + ") SELECT SCOPE_IDENTITY()";
            SqlCommand cmd = new SqlCommand(q, this.con);

            var newId = Convert.ToInt32(cmd.ExecuteScalar());

            this.con.Close();

            return(newId);
        }
        public PartieDTO GetPartie(int?id)
        {
            this.con.Open();
            string     commande = "select * from partie where Id=" + id;
            SqlCommand cmd1     = new SqlCommand(commande, this.con);

            SqlDataReader reader = cmd1.ExecuteReader();

            PartieDTO game = new PartieDTO();

            while (reader.Read())
            {
                game.Id           = (int?)reader.GetValue(0);
                game.IdPersonnage = (int?)reader.GetValue(1);
                game.Difficulte   = (int?)reader.GetValue(2);
            }

            this.con.Close();
            return(game);
        }
Beispiel #3
0
        public int?GenerateNewGame(string nomPerso, int difficultePartie)
        {
            HarryPeloteur_DAL.PersonneDTO perso = new HarryPeloteur_DAL.PersonneDTO()
            {
                Id            = 0,
                SalleActuelle = 0,
                Nom           = nomPerso,
                Pv            = 1000,
                Force         = 20,
                Fuite         = 20,
                Dexterite     = 20,
                Xp            = 1,
                Po            = 10
            };
            perso.Id = db.InsertPersonne(perso);

            HarryPeloteur_DAL.PartieDTO partie = new HarryPeloteur_DAL.PartieDTO()
            {
                Id           = 0,
                IdPersonnage = perso.Id,
                Difficulte   = difficultePartie
            };
            partie.Id = db.InsertPartie(partie);
            HarryPeloteur_DAL.SalleDTO salle = new HarryPeloteur_DAL.SalleDTO()
            {
                Id          = 0,
                IdPartie    = partie.Id,
                Coordonnees = new int[] { 0, 0 },
                IdContenu   = 0,
                TypeContenu = 0,
                Portes      = new int[] { 1, 1, 1, 1 },
                Etat        = 0
            };

            salle.Id            = db.InsertSalle(salle);
            perso.SalleActuelle = salle.Id;
            db.UpdatePersonne(perso);

            return(partie.Id);
        }
        public List <PartieDTO> GetParties()
        {
            this.con.Open();
            string     commande = "select * from partie";
            SqlCommand cmd1     = new SqlCommand(commande, this.con);

            SqlDataReader reader = cmd1.ExecuteReader();

            List <PartieDTO> gameList = new List <PartieDTO>();

            while (reader.Read())
            {
                PartieDTO game = new PartieDTO();
                game.Id           = (int?)reader.GetValue(0);
                game.IdPersonnage = (int?)reader.GetValue(1);
                game.Difficulte   = (int?)reader.GetValue(2);

                gameList.Add(game);
            }

            this.con.Close();
            return(gameList);
        }