コード例 #1
0
        public async Task <GetBadgesResponse> Get()
        {
            var response = new GetBadgesResponse
            {
                Badges = await Task.FromResult(Badges.BadgeList),
            };

            if (MemoryCacher.GetValue(Cache.BadgeRanking) is IEnumerable <BadgeRanking> cacheBadgeRankings)
            {
                response.BadgeRankings = cacheBadgeRankings;
            }
            else
            {
                var badgeRankings = await _databaseRepository.GetBadgeRanking();

                if (badgeRankings != null)
                {
                    MemoryCacher.Add(Cache.BadgeRanking, badgeRankings, DateTimeOffset.UtcNow.AddDays(1));
                }

                response.BadgeRankings = badgeRankings;
            }

            return(response);
        }
コード例 #2
0
        public async Task <GetBadgesResponse> GetBadges(GetBadgesRequest request)
        {
            var result = new GetBadgesResponse
            {
                Data = await this.badgesRepository.GetBadges()
            };

            return(result);
        }
コード例 #3
0
        public static GetBadgesWebResponse AsWebResponse(this GetBadgesResponse response)
        {
            var result = new GetBadgesWebResponse
            {
                Errors       = response.Errors,
                IsSuccessful = response.IsSuccessful,
                Message      = response.Message,
                StatusCode   = response.StatusCode,
                Data         = response.Data
            };

            return(result);
        }