Exemple #1
0
        public async Task <RequestResult> ChangePassword(User user, CancellationToken cancellationToken)
        {
            var requestResult = new RequestResult();

            var requestResultAuthenticateUser = await AuthenticateUser(user, cancellationToken);

            requestResult.Add(requestResultAuthenticateUser);

            if (requestResultAuthenticateUser.Succeeded)
            {
                requestResultAuthenticateUser.Model.Password = BCrypt.Net.BCrypt.HashPassword(user.NewPassword);
                await _iRepoBase.Update(requestResultAuthenticateUser.Model, cancellationToken);
            }

            return(requestResult);
        }
Exemple #2
0
        private async Task <RequestResult <RefreshToken> > Update(CancellationToken cancellationToken, int userId, EntityRefreshToken entityRefreshToken)
        {
            var requestResult = new RequestResult <RefreshToken>();

            entityRefreshToken.Token = CreateToken();
            await _iRepoBase.Update(entityRefreshToken, cancellationToken);

            requestResult.Model = _iMapper.Map <RefreshToken>(entityRefreshToken);

            return(requestResult);
        }
Exemple #3
0
        public async Task <RequestResult> Update(Fibonacci fibonacci, CancellationToken cancellationToken)
        {
            var requestResult   = new RequestResult();
            var entityFibonacci = await _iRepoBase.ReadSingle <EntityFibonacci>(a => a.FibonacciId == fibonacci.FibonacciId, cancellationToken);

            entityFibonacci.Iterations = fibonacci.Iterations;
            entityFibonacci.Total      = fibonacci.Total;

            await _iRepoBase.Update(entityFibonacci, cancellationToken);

            return(requestResult);
        }
        public async Task <RequestResult> Update(Fibonacci fibonacci, CancellationToken cancellationToken)
        {
            var requestResult   = new RequestResult();
            var entityFibonacci = await _iRepoBase.ReadSingle <EntityFibonacci>(a => a.FibonacciId == fibonacci.FibonacciId, cancellationToken);

            entityFibonacci.Iterations = fibonacci.Iterations;

            if (fibonacci.Iterations > 46)
            {
                requestResult.Errors.Add("Cannot compute for more than 46");
                entityFibonacci.Total = 0;
            }
            else
            {
                entityFibonacci.Total = FibonacciTotal(fibonacci.Iterations);
            }

            await _iRepoBase.Update(entityFibonacci, cancellationToken);

            return(requestResult);
        }
Exemple #5
0
 public void Update(T entity)
 {
     repo.Update(entity);
 }