public BidDetails LastBidOfUser(int userId, int productId)
        {
            BidDetails         latestBid = null;
            RedisKeyParameters redisObj  = new RedisKeyParameters
            {
                UserId    = userId,
                ProductId = productId
            };
            string bidHashAllKey           = RedisCacheManager.GetRedisKey("BidHashKey", redisObj);
            string bidSortedSetSupplierKey = RedisCacheManager.GetRedisKey("AllBidsSortedSetForSupplierKey", redisObj);

            RedisValue[] redisValuesSortedSet;

            redisValuesSortedSet = RedisCacheManager.GetSortedSetRangeByRankDescending(bidSortedSetSupplierKey, 0, 0);
            if (redisValuesSortedSet != null && redisValuesSortedSet.Any())
            {
                latestBid = RedisCacheManager.GetHashItemValue <BidDetails>(bidHashAllKey, redisValuesSortedSet[0]);
            }
            return(latestBid ?? null);
        }
        public int GetRankUser(int productId, int userId)
        {
            RedisKeyParameters redisObj = new RedisKeyParameters
            {
                ProductId = productId,
                UserId    = userId
            };
            string bidHashAllKey        = RedisCacheManager.GetRedisKey("BidHashKey", redisObj);
            string bidSortedSetKey      = RedisCacheManager.GetRedisKey("AllBidsSortedSetKey", redisObj);
            var    redisValuesSortedSet = RedisCacheManager.GetSortedSetRangeByRankDescending(bidSortedSetKey);

            HashEntry[] redisKeyValuesHash = RedisCacheManager.GetHashAllValueAsKeyValuePair(bidHashAllKey);
            List <int>  listBids           = new List <int>();

            if (redisKeyValuesHash != null && redisValuesSortedSet != null && redisValuesSortedSet.Length > 0 && redisKeyValuesHash.Length > 0)
            {
                foreach (var value in redisValuesSortedSet)
                {
                    string _bidObj = redisKeyValuesHash.Where(x => x.Name == value.ToString()).Select(x => x.Value).FirstOrDefault();
                    listBids.Add(JsonConvert.DeserializeObject <BidDetails>(_bidObj).UserId);
                }
            }
            return(listBids.IndexOf(userId) + 1);
        }