public LeaguesResult GetAllLeagues(string userName)
        {
            var result = new LeaguesResult();

            try
            {
                var user = _cache.RefreshAndGet(
                    _cache.Users,
                    userName,
                    new UserNotFoundException(string.Format("user name: {0} not found, please re-login to server.", userName))
                    );

                result.Leagues = _cache.Leagues.Select(domainLeaguePair => new LeaguesResult.League()
                {
                    ID       = domainLeaguePair.Key,
                    MaxLevel = domainLeaguePair.Value.MaxLevel,
                    MinLevel = domainLeaguePair.Value.MinLevel,
                    Name     = domainLeaguePair.Value.Name,
                    IsFull   = domainLeaguePair.Value.IsFull,
                }).ToArray();

                result.RelevantID = _cache.GameCenter.GetRelevantLeague(user.Level);
            }
            catch (PokerException e)
            {
                result.Success      = false;
                result.ErrorMessage = e.Message;
                Logger.Error(e, this);
            }

            return(result);
        }
        public HttpResponseMessage GetAllLeagues(string userName)
        {
            var result = new LeaguesResult();

            try
            {
                result = service.GetAllLeagues(userName);
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.Success      = false;
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, result));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }