Ejemplo n.º 1
0
        public async Task <IActionResult> SetCardRating(Guid cardId, int rating)
        {
            var userId = await UserServices.UserIdFromContextAsync(HttpContext, userManager);

            var request = new SetCardRating.Request(userId, cardId, rating);

            await new SetCardRating(callContext).RunAsync(request);
            return(ControllerResultWithToast.Success($"{Get("RatingSavedOk")} {rating}\u2605", this));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> SetCardRating(Guid cardId, int rating)
        {
            try
            {
                var user = await userManager.GetUserAsync(HttpContext.User);

                var request = new SetCardRating.Request(user, cardId, rating);
                await new SetCardRating(dbContext).RunAsync(request);
                return(Ok());
            }
            catch (Exception e)
            {
                return(ControllerError.BadRequest(e, this));
            }
        }
Ejemplo n.º 3
0
        async public Task RunAsync()
        {
            var author = await dbContext.Users.Where(u => u.UserName == "VoltanBot").SingleAsync();

            var ratingUser = await dbContext.Users.Where(u => u.UserName == "VoltanBot").SingleAsync();

            var cardIds = await dbContext.Cards.Where(card => card.VersionCreator.Id == author.Id).Select(card => card.Id).ToListAsync();

            var rater = new SetCardRating(dbContext.AsCallContext());

            foreach (var cardId in cardIds)
            {
                var request = new SetCardRating.Request(ratingUser.Id, cardId, 5);
                await rater.RunAsync(request);
            }

            await dbContext.SaveChangesAsync();

            logger.LogInformation($"Rating finished");
        }