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