/// <summary> /// Retorna as compras efetuadas por cliente /// </summary> /// <returns></returns> public List <History> ListarPorId(String clientId) { List <History> lista = new List <History>(); using (var bd = new BDEngine()) { sql.Clear(); sql.Append(@" select h.client_id, h.order_id, o.credit_card, o.total_to_pay, o.date from History h(nolock) inner join Orders o(nolock) on(o.order_id = h.order_id) where h.client_id = '{0}' order by o.date "); var dr = bd.ObterReader(string.Format(sql.ToString(), clientId)); if (dr.HasRows) { while (dr.Read()) { History history = new History(); history.card_number = dr["credit_card"].ToString(); history.client_id = dr["client_id"].ToString(); history.value = Convert.ToInt32(dr["total_to_pay"]); history.order_id = dr["order_id"].ToString(); history.date = dr["date"].ToString(); lista.Add(history); } } } return(lista); }
/// <summary> /// Lista todos os produtos /// </summary> /// <returns></returns> public List <Product> Listar() { List <Product> lista = new List <Product>(); using (var bd = new BDEngine()) { sql.Clear(); sql.Append(@" SELECT product_id, artist, year, album, price, store, thumb, date FROM Product ORDER BY album DESC "); var dr = bd.ObterReader(sql.ToString()); if (dr.HasRows) { while (dr.Read()) { Product product = new Product(); product.product_id = dr["product_id"].ToString(); product.artist = dr["artist"].ToString(); product.year = Convert.ToInt32(dr["year"]); product.album = dr["album"].ToString(); product.price = Convert.ToInt32(dr["price"]); product.store = dr["store"].ToString(); product.thumb = dr["thumb"].ToString(); product.date = dr["date"].ToString(); lista.Add(product); } } } return(lista); }