Ejemplo n.º 1
0
        private async Task <CyborgViewModel[]> RefreshCache()
        {
            var cyborgs = await _cyborgService.GetCyborgsBy(string.Empty, null);

            return(cyborgs.Select(e => new CyborgViewModel(e)).ToArray());
            //TODO: determine better caching process, perhaps at the services layer instead the api boundary
            //return _helpersManager.Cache.Set((DateTime.Today, ActorType.Cyborg), robots.Select(e => new CyborgViewModel(e)).ToArray());
        }
Ejemplo n.º 2
0
        public override async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            //TODO: invalidate cache, this is inefficient
            var robots = await _cyborgService.GetCyborgsBy(string.Empty, null);

            _helpersManager.Cache.Set((DateTime.Today, ActorType.Cyborg), robots.Select(e => new CyborgViewModel(e)).ToArray());
            await next();
        }
Ejemplo n.º 3
0
        private async Task <CyborgViewModel[]> RefreshCyborgCache()
        {
            var cyborgs = await _cyborgService.GetCyborgsBy(string.Empty, null);

            return(cyborgs.Select(e => new CyborgViewModel(e)).ToArray());
            //TODO: determine better caching process, perhaps at the services layer instead the api boundary
            //return _helpersManager.Cache.Set(GetLeaderBoardCyborgKey(), cyborgs.Select(e => new CyborgViewModel(e)).ToArray());
        }
Ejemplo n.º 4
0
        private async Task <ICanPerformErrand> DeactivateRandomCyborg(ICanPerformErrand actor)
        {
            var targettedActors = await _cyborgService.GetCyborgsBy(string.Empty, null);

            var randomSkipCount   = _randomGenerator.Next(1, targettedActors.Count());
            var actorToDeactivate = await _cyborgService.GetCyborg(randomSkipCount);

            if (actorToDeactivate != null)
            {
                actorToDeactivate.IsActive   = false;
                actorToDeactivate.KilledById = actor.Id;
                return(actorToDeactivate);
            }
            else
            {
                return(null);
            }
        }