コード例 #1
0
ファイル: WebApiController.cs プロジェクト: dkempner/voat
        public ApiBadge BadgeInfo(string badgeId)
        {
            ApiBadge badgeInfo = CacheHandler.Register<ApiBadge>(String.Format("LegacyApi.ApiBadge.{0}", badgeId),
             new Func<ApiBadge>(() =>
             {
                 using (voatEntities db = new voatEntities(CONSTANTS.CONNECTION_READONLY))
                 {
                     var badge = _db.Badges.Find(badgeId);

                     if (badge == null)
                     {
                         throw new HttpResponseException(HttpStatusCode.NotFound);
                     }

                     var resultModel = new ApiBadge
                     {
                         BadgeId = badge.BadgeId,
                         BadgeGraphics = badge.BadgeGraphics,
                         Name = badge.BadgeName,
                         Title = badge.BadgeTitle
                     };

                     return resultModel;
                 }
             }), TimeSpan.FromHours(5));
            return badgeInfo;
        }
コード例 #2
0
ファイル: WebApiController.cs プロジェクト: kiwwisk/voat
        public ApiBadge BadgeInfo(string badgeId)
        {
            var badge = _db.Badges.Find(badgeId);

            if (badge == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var resultModel = new ApiBadge
            {
                BadgeId = badge.BadgeId,
                BadgeGraphics = badge.BadgeGraphics,
                Name = badge.BadgeName,
                Title = badge.BadgeTitle
            };

            return resultModel;
        }