Created
September 30, 2012 18:36
-
-
Save RyanDurkin/3808103 to your computer and use it in GitHub Desktop.
Product Price Utilities Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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