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; }
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; }