Exemplo n.º 1
0
        public bool CreateGevecht(Account account, Tegenstander tegenstander)
        {
            string query = "INSERT INTO dbo.Gevecht " +
                           "(GebruikerId, GebruikerPokemonId, TegenstanderPokemonId, GebruikerPokemonHp, TegenstanderPokemonHp) " +
                           "VALUES (@GebruikerId, @GebruikerPokemonId, @TegenstanderPokemonId, @GebruikerPokemonHp, @TegenstanderPokemonHp)";

            try
            {
                using (SqlConnection conn = new SqlConnection(_connstring))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(query, conn))
                    {
                        cmd.Parameters.AddWithValue("@GebruikerId", account.Id);
                        cmd.Parameters.AddWithValue("@GebruikerPokemonId", account.Pokemon[0].TeamId);
                        cmd.Parameters.AddWithValue("@TegenstanderPokemonId", tegenstander.Pokemon[0].TeamId);
                        cmd.Parameters.AddWithValue("@GebruikerPokemonHp", account.Pokemon[0].MaxHP);
                        cmd.Parameters.AddWithValue("@TegenstanderPokemonHp", tegenstander.Pokemon[0].MaxHP);

                        cmd.ExecuteNonQuery();
                    }
                    conn.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(true);
        }
Exemplo n.º 2
0
        public Tegenstander GetById(int id, int gebruikerId)
        {
            Tegenstander t = gCtx.GetById(id, gebruikerId);

            t.Pokemon = GetAllPokemonOfTegenstander(t.Id, gebruikerId);
            return(t);
        }
Exemplo n.º 3
0
        public Tegenstander GetById(int id, int gebruikerId)
        {
            Tegenstander t     = new Tegenstander();
            string       query =
                "SELECT * " +
                "FROM dbo.Tegenstander " +
                "WHERE Id = @Id";

            try
            {
                using (SqlConnection conn = new SqlConnection(_connstring))
                {
                    conn.Open();
                    SqlCommand pokcmd = new SqlCommand(query, conn);

                    pokcmd.Parameters.AddWithValue("@Id", id);


                    using (SqlDataReader reader = pokcmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            t = new Tegenstander((int)reader["Id"], reader["Naam"].ToString(), null);
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(t);
        }
 public bool CreateGevecht(Account account, Tegenstander tegenstander)
 {
     throw new NotImplementedException();
 }