public async Task <RequestResult <Fibonacci> > Create(Fibonacci fibonacci, CancellationToken cancellationToken) { var requestResult = new RequestResult <Fibonacci>(); var entityFibonacci = _iMapper.Map <EntityFibonacci>(fibonacci); await _iRepoBase.Create(entityFibonacci, cancellationToken); requestResult.Model = _iMapper.Map <Fibonacci>(entityFibonacci); return(requestResult); }
public async Task <RequestResult <RefreshToken> > Create(int userId, CancellationToken cancellationToken) { var requestResult = new RequestResult <RefreshToken>(); var entityRefreshToken = new EntityRefreshToken { UserId = userId, Token = CreateToken(), }; await _iRepoBase.Create(entityRefreshToken, cancellationToken); requestResult.Model = _iMapper.Map <RefreshToken>(entityRefreshToken); return(requestResult); }
public async Task <RequestResult <ExceptionLog> > Create(CancellationToken cancellationToken, ExceptionLog exceptionLog, string applicationName) { var requestResult = new RequestResult <ExceptionLog>(); var entityExceptionLog = _iMapper.Map <EntityExceptionLog>(exceptionLog); entityExceptionLog.ApplicationName = applicationName; entityExceptionLog.CreatedDateUtc = DateTime.UtcNow; if (entityExceptionLog.InnerException != null) { entityExceptionLog.InnerException.CreatedDateUtc = DateTime.UtcNow; } await _iRepoBase.Create(entityExceptionLog, cancellationToken); requestResult.Model = _iMapper.Map <ExceptionLog>(entityExceptionLog); return(requestResult); }
public async Task <RequestResult <Fibonacci> > Create(Fibonacci fibonacci, CancellationToken cancellationToken) { var requestResult = new RequestResult <Fibonacci>(); var entityFibonacci = _iMapper.Map <EntityFibonacci>(fibonacci); if (fibonacci.Iterations > 46) { requestResult.Errors.Add("Cannot compute for more than 46"); entityFibonacci.Total = 0; } else { entityFibonacci.Total = FibonacciTotal(fibonacci.Iterations); } await _iRepoBase.Create(entityFibonacci, cancellationToken); requestResult.Model = _iMapper.Map <Fibonacci>(entityFibonacci); return(requestResult); }
public async Task <RequestResult <User> > Create(User user, CancellationToken cancellationToken) { var requestResult = new RequestResult <User>(); var usernameExists = await _iRepoBase.Exists <EntityUser>(a => a.Username == user.Username, cancellationToken); if (!usernameExists) { var entityUser = _iMapper.Map <EntityUser>(user); entityUser.Password = BCrypt.Net.BCrypt.HashPassword(user.Password); await _iRepoBase.Create(entityUser, cancellationToken); entityUser.Password = string.Empty; requestResult.Model = _iMapper.Map <User>(entityUser); } else { requestResult.Errors.Add("Username already exists"); } return(requestResult); }
public void Create(T entity) { repo.Create(entity); }