public IEnumerable <ShoppingCartItem> GetByPostId(int postId, bool isCache = true) { IEnumerable <ShoppingCartItem> shoppingCartItem; if (isCache) { var sbKey = new StringBuilder(); sbKey.AppendFormat(CacheShoppingcartitemKey, "GetByPostId"); sbKey.Append(postId); var key = sbKey.ToString(); shoppingCartItem = _cacheManager.GetCollection <ShoppingCartItem>(key); if (shoppingCartItem == null) { shoppingCartItem = _shoppingCartItemRepository.FindBy(x => x.PostId == postId); _cacheManager.Put(key, shoppingCartItem); } } else { shoppingCartItem = _shoppingCartItemRepository.FindBy(x => x.PostId == postId); } return(shoppingCartItem); }
public List <ShoppingCartItem> GetCartDetails(int id) { return(_shoppingCartItemRepository.FindBy(x => x.AccountUserId == id).Cast <ShoppingCartItem>().ToList()); }