示例#1
0
        public List <PopsRating> list()
        {
            string sql = "select avg(rating_pos), id_pop from pops_rating group by id_pop";

            DataTable         registos = DB.Instance.devolveConsulta(sql);
            List <PopsRating> lista    = new List <PopsRating> ();

            foreach (DataRow data in registos.Rows)
            {
                PopsRating novo = new PopsRating();
                novo.id_pop     = int.Parse(data[1].ToString());
                novo.rating_pos = int.Parse(data[0].ToString());
                lista.Add(novo);
            }
            return(lista);
        }
示例#2
0
        public void create(PopsRating novo)
        {
            string sql = @"INSERT INTO pops_rating(id_user, id_pop, rating_pos)
                        VALUES (@id_user,@id_pop, @rating_pos)";

            List <SqlParameter> parametros = new List <SqlParameter> ()
            {
                new SqlParameter()
                {
                    ParameterName = "@id_user", SqlDbType = SqlDbType.Int, Value = novo.id_user
                },
                new SqlParameter()
                {
                    ParameterName = "@id_pop", SqlDbType = SqlDbType.Int, Value = novo.id_pop
                },
                new SqlParameter()
                {
                    ParameterName = "@rating_pos", SqlDbType = SqlDbType.Int, Value = novo.rating_pos
                },
            };

            DB.Instance.executaComando(sql, parametros);
        }