Exemple #1
0
        public async Task <User> BanUserAsync(BanDto banDto)
        {
            var user = await FindUserForBanAsync(banDto?.UserId).ConfigureAwait(false);

            var ban = await _banService.AddBan(banDto).ConfigureAwait(false);

            return(user);
        }
        private async Task <bool> InsertBansInTransaction(List <Ban> bansToInsert, int accountId)
        {
            bool isBlocked = true;

            using (var transaction = database.BeginTransaction().Transaction)
            {
                foreach (var b in bansToInsert)
                {
                    if (b.Serial != null && !await serialService.SerialExists(b.Serial, accountId))
                    {
                        throw new ServerException("User serial does not exist in database");
                    }

                    isBlocked = isBlocked && await banService.AddBan(b) != null;
                }

                transaction.Complete();
            }

            return(isBlocked);
        }