Skip to content

Instantly share code, notes, and snippets.

@RyanDurkin
Created September 30, 2012 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanDurkin/3808103 to your computer and use it in GitHub Desktop.
Save RyanDurkin/3808103 to your computer and use it in GitHub Desktop.
Product Price Utilities Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class ProductPriceUtilities
{
public static List<ProductPrice> GetAllPrices()
{
//create a list to return
List<ProductPrice> prices = new List<ProductPrice>();
//set required variables
var client = new CDS.ContentDeliveryService(new Uri("http://bbtrid04:8080/cd_webservice/odata.svc", UriKind.Absolute));
int publicationId = 7;
int componentTemplateId = 31936;
//use LINQ to extract the component presentations from the content delivery web service
var componentPresentations = client.ComponentPresentations
.Where(u => u.PublicationId == publicationId && u.TemplateId == componentTemplateId)
.ToList();
//deserialize each item into a ProductPrice and add to the list
foreach (var cp in componentPresentations)
{
prices.Add(ProductPrice.Deserialize(cp.PresentationContent));
}
//return the prices
return prices;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment