public List <Product> GetAllProduct() { List <Product> products = new List <Product>(); dynamic rs = session.Execute($"select * from {Product.TABLE_NAME};"); foreach (Row row in rs) { products.Add(CassandraMapper.DBProductMapper(row)); } return(products); }
public List <WishList> GetAllWishList() { List <WishList> wishLists = new List <WishList>(); RowSet rows = session.Execute($"select * from {WishList.TABLE_NAME};"); foreach (Row row in rows) { wishLists.Add(CassandraMapper.DBWishListMapper(row)); } return(wishLists); }
//public List<ProductDTO> GetAllProductFromWish(Guid wishId) //{ // List<ProductDTO> products = new List<ProductDTO>(); // PreparedStatement wishListPS = session.Prepare("select * from wishlist where wish_id=? ALLOW FILTERING"); // BoundStatement wishListBS = wishListPS.Bind(wishId.ToString()); // RowSet wishListResult = session.Execute(wishListBS); // PreparedStatement productPreparedStatement = session.Prepare("select * from product where id = ?"); // foreach (Row wishlistRow in wishListResult) // { // if (wishlistRow.GetValue<int>("item_type") == (int)ItemType.Product) // { // Guid productId = Helper.SafeGuidParse(wishlistRow.GetValue<string>("item_id")); // if (productId != new Guid()) // { // RowSet productRowSet = session.Execute(productPreparedStatement.Bind(productId.ToString())); // foreach (Row productRow in productRowSet) // { // products.Add(new ProductDTO(productRow)); // } // //productBatch.Add(productPreparedStatement.Bind(productId.ToString())); // } // } // else if (wishlistRow.GetValue<int>("item_type") == (int)ItemType.Wish) // { // Guid reWishId = Helper.SafeGuidParse(wishlistRow.GetValue<string>("item_id")); // if (reWishId != new Guid()) // { // products.AddRange(GetAllProductFromWish(reWishId)); // } // } // } // return products; //} public List <Wish> GetAllWish() { List <Wish> wishes = new List <Wish>(); RowSet wishesResult = session.Execute($"select * from {Wish.TABLE_NAME};"); foreach (Row wishRow in wishesResult) { wishes.Add(CassandraMapper.DBWishMapper(wishRow)); } return(wishes); }
// This GetSingleProduct can return null if there is no product to return for that id; public Product GetSingleProduct(Guid productId) { PreparedStatement ps = session.Prepare($"SELECT * FROM {Product.TABLE_NAME} where {Product.COL_ID}=?;"); BoundStatement statement = ps.Bind(productId.ToString()); RowSet rowSet = session.Execute(statement); foreach (Row row in rowSet) { return(CassandraMapper.DBProductMapper(row)); } return(null); }
// This GetSingleWish can return null if there is no wish to return for that id; public Wish GetSingleWish(Guid productId) { Wish wish = null; PreparedStatement preparedStatement = session.Prepare($"select * from {Wish.TABLE_NAME} where {Wish.COL_ID}=?"); RowSet wishesResult = session.Execute(preparedStatement.Bind(productId.ToString())); foreach (Row wishRow in wishesResult) { wish = CassandraMapper.DBWishMapper(wishRow); } return(wish); }
public List <WishList> GetWishListByWish(Guid wishId) { List <WishList> wishLists = new List <WishList>(); List <ProductDTO> products = new List <ProductDTO>(); PreparedStatement wishListPS = session.Prepare($"select * from {WishList.TABLE_NAME} where {WishList.COL_WISH_ID}=? ALLOW FILTERING"); BoundStatement wishListBS = wishListPS.Bind(wishId.ToString()); RowSet rows = session.Execute(wishListBS); foreach (Row row in rows) { wishLists.Add(CassandraMapper.DBWishListMapper(row)); } return(wishLists); }