コード例 #1
0
        public ShoppingCartItem GetById(int id, bool isCache = true)
        {
            ShoppingCartItem shoppingCartItem;

            if (isCache)
            {
                var sbKey = new StringBuilder();
                sbKey.AppendFormat(CacheShoppingcartitemKey, "GetById");
                sbKey.Append(id);

                var key = sbKey.ToString();
                shoppingCartItem = _cacheManager.Get <ShoppingCartItem>(key);
                if (shoppingCartItem == null)
                {
                    shoppingCartItem = _shoppingCartItemRepository.GetById(id);
                    _cacheManager.Put(key, shoppingCartItem);
                }
            }
            else
            {
                shoppingCartItem = _shoppingCartItemRepository.GetById(id);
            }

            return(shoppingCartItem);
        }
コード例 #2
0
 public ShoppingCartItem GetById(int id)
 {
     return(_shoppingCartItemRepository.GetById(id));
 }