private static Reviews Reviews(string customerId) { Assert.ValidInput(customerId, "customerId"); if(ServiceCache.IsInCache<Reviews>(customerId)) { var cachedReviews = (Reviews) ServiceCache.GetFromCache<Reviews>(customerId); if (cachedReviews != null) { return cachedReviews; } } var amazonResponse = new AmazonFactory(BuildRequest(customerId, null)).GetResponse(); HandleErrors(amazonResponse.Errors); return new Reviews(amazonResponse.Reviews.OrderByDescending(r => r.Date)).AddToCache(customerId); }
private static Wishlist Wishlist(string listId) { Assert.ValidInput(listId, "listId"); if(ServiceCache.IsInCache<Wishlist>(listId)) { var cachedWishlist = (Wishlist) ServiceCache.GetFromCache<Wishlist>(listId); if (cachedWishlist != null) { return cachedWishlist; } } var amazonResponse = new AmazonFactory(BuildRequest(null, listId)).GetResponse(); HandleErrors(amazonResponse.Errors); return new Wishlist(amazonResponse.Products.OrderBy(p => p.AuthorsMLA).ThenBy(p => p.Title)).AddToCache(listId); }