Ejemplo n.º 1
0
        public IQueryable <Badge> GetBadgeQuery(BadgeTypeEnum type)
        {
            switch (type)
            {
            case BadgeTypeEnum.BadgeDrop:
                return(context.Badges.OfType <BadgeDrops>());

            case BadgeTypeEnum.BadgeTrail:
                return(context.Badges.OfType <BadgeTrails>());

            case BadgeTypeEnum.BadgeSummit:
                return(context.Badges.OfType <BadgeSummit>());

            default:
                return(null);
            }
        }
Ejemplo n.º 2
0
        public async Task <Badge> UpdateBadgeLevel(int badgeId, int newBadgeLevel, BadgeTypeEnum type)
        {
            if (type == BadgeTypeEnum.BadgeDrop)
            {
                var badge = (BadgeDrops)await context.Badges.FirstOrDefaultAsync(b => b.Id == badgeId);

                badge.BadgeLevel = newBadgeLevel;
                await SaveAll();

                return(badge);
            }
            else
            {
                var badge = (BadgeTrails)await context.Badges.FirstOrDefaultAsync(b => b.Id == badgeId);

                badge.BadgeLevel = newBadgeLevel;
                await SaveAll();

                return(badge);
            }
        }
Ejemplo n.º 3
0
        public async Task <PagedList <Badge> > GetBadgesByType(BadgeParams badgeParams, BadgeTypeEnum type)
        {
            logger.LogInformation($"GetBadgesByType was called with parameter {type}");
            var badge = GetBadgeQuery(type);

            if (badge == null)
            {
                logger.LogError($"Badge type was not found: {type}");
                return(null);
            }

            return(await PagedList <Badge> .CreateAsync(badge, badgeParams.PageNumber, badgeParams.PageSize));
        }