public CreateAccountHandler( IWriteOnlyUnitOfWork unitOfWork, IAccountFactory factory) { this.factory = factory; this.unitOfWork = unitOfWork; }
public AccountService(IAccountFactory accountFactory, IAmountFactory amountFactory, IStatementCollectionFactory statementCollectionFactory, IStatementFactory statementFactory) { _accountFactory = accountFactory ?? throw new ArgumentNullException(nameof(accountFactory)); _amountFactory = amountFactory ?? throw new ArgumentNullException(nameof(amountFactory)); _statementCollectionFactory = statementCollectionFactory ?? throw new ArgumentNullException(nameof(statementCollectionFactory)); _statementFactory = statementFactory ?? throw new ArgumentNullException(nameof(statementFactory)); }
public async Task <IActionResult> Update(Guid id, [FromBody] Dictionary <string, string> data) { IActionResult result = null; bool locked = default; try { if (result == null && data == null) { result = BadRequest("Missing patch data"); } if (result == null && (!data.ContainsKey("Locked") || string.IsNullOrEmpty(data["Locked"]))) { result = BadRequest("Missing Locked value"); } if (result == null && Guid.Empty.Equals(id)) { result = BadRequest("Invalid account id"); } if (result == null && !UserCanAccessAccount(id)) { result = StatusCode(StatusCodes.Status401Unauthorized); } if (result == null && !bool.TryParse(data["Locked"], out locked)) { result = BadRequest("Invalid locked value. Expecting 'True' or 'False'"); } if (result == null) { using (ILifetimeScope scope = _container.BeginLifetimeScope()) { SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>(); CoreSettings settings = settingsFactory.CreateAccount(_settings.Value); IAccountFactory accountFactory = scope.Resolve <IAccountFactory>(); IAccount innerAccount = await accountFactory.Get(settings, id); if (innerAccount == null) { result = NotFound(); } else { IAccountSaver saver = scope.Resolve <IAccountSaver>(); await saver.UpdateLocked(settings, innerAccount.AccountId, locked); result = Ok(); } } } } catch (Exception ex) { using (ILifetimeScope scope = _container.BeginLifetimeScope()) { await LogException(ex, scope.Resolve <IExceptionService>(), scope.Resolve <SettingsFactory>(), _settings.Value); } result = StatusCode(StatusCodes.Status500InternalServerError); } return(result); }
public AccountService(IRepository <ITransaction> transactionRepo, IRepository <IAccount> accoutRepo, ITransactionFactory transactionFactory, IAccountFactory accountFactory, IPrincipal principal) { if (transactionRepo == null) { throw new ArgumentNullException("transactionRepo"); } if (accoutRepo == null) { throw new ArgumentNullException("accoutRepo"); } if (transactionFactory == null) { throw new ArgumentNullException("transactionFactory"); } if (accountFactory == null) { throw new ArgumentNullException("accountFactory"); } if (principal == null) { throw new ArgumentNullException("principal"); } _transactionRepo = transactionRepo; _accoutRepo = accoutRepo; _transactionFactory = transactionFactory; _accountFactory = accountFactory; _username = principal.Identity.Name; }
public Bank( IAccountFactory accountFactory, ICurrencyActions currencyActions) { this._accountFactory = accountFactory; this._currencyActions = currencyActions; }
public ICredit Deposit(IAccountFactory entityFactory, PositiveMoney amountToDeposit) { var credit = entityFactory.NewCredit(this, amountToDeposit, DateTime.UtcNow); Credits.Add(credit); return(credit); }
static void Main(string[] args) { IAccountService service = resolver.Get <IAccountService>(); IAccountNumberCreateService accountNumberCreator = resolver.Get <IAccountNumberCreateService>(); IAccountFactory accountFactory = resolver.Get <IAccountFactory>(); //service.OpenAccount("Account owner 1", "BaseAccount", accountNumberCreator); //service.OpenAccount("Account owner 2", "BaseAccount", accountNumberCreator); //service.OpenAccount("Account owner 3", "SilverAccount", accountNumberCreator); //service.OpenAccount("Account owner 4", "BaseAccount", accountNumberCreator); var creditNumbers = service.GetAllAccounts().Select(acc => acc.AccountNumber).ToArray(); foreach (var t in creditNumbers) { service.DepositAccount(t, 100); } foreach (var item in service.GetAllAccounts()) { Console.WriteLine(item); } foreach (var t in creditNumbers) { service.WithdrawAccount(t, 10); } foreach (var item in service.GetAllAccounts()) { Console.WriteLine(item); } Console.ReadKey(); }
public async Task <IActionResult> GetByEmailAddress(string emailAddress) { IActionResult result = null; using (ILifetimeScope scope = _container.BeginLifetimeScope()) { SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>(); CoreSettings settings = settingsFactory.CreateAccount(_settings.Value); IUserFactory userFactory = scope.Resolve <IUserFactory>(); IEnumerable <IUser> users = await userFactory.GetByEmailAddress(settings, emailAddress); IAccountFactory accountFactory = scope.Resolve <IAccountFactory>(); ConcurrentBag <Task <IEnumerable <IAccount> > > accounts = new ConcurrentBag <Task <IEnumerable <IAccount> > >(); users.AsParallel().ForAll(user => accounts.Add(accountFactory.GetByUserId(settings, user.UserId))); IMapper mapper = MapperConfigurationFactory.CreateMapper(); result = Ok( (await Task.WhenAll <IEnumerable <IAccount> >(accounts)) .SelectMany(results => results) .Where(a => UserCanAccessAccount(a.AccountId)) .Select <IAccount, Account>(innerAccount => mapper.Map <Account>(innerAccount)) .ToList() ); } return(result); }
public View(string header, IShell shell, IRepository repo, IAccountFactory accountFactory) { Header = header; Shell = shell; Repository = repo; AccountFactory = accountFactory; }
public ViewFactory(IRepository repository, IShell shell, IAccountFactory factory, ITransferService transfer) { this.Repository = repository; this.ConsoleShell = shell; this.AccountFactory = factory; this.TransferService = transfer; }
/// <summary> /// Initializes a new instance of the <see cref="AccountService" /> class. /// </summary> /// <param name="accountFactory">Account Factory.</param> /// <param name="accountRepository">Account Repository.</param> public AccountService( IAccountFactory accountFactory, IAccountRepository accountRepository) { this._accountFactory = accountFactory; this._accountRepository = accountRepository; }
public AccountService( IAccountFactory accountFactory, IAccountRepository accountRepository) { _accountFactory = accountFactory; _accountRepository = accountRepository; }
public async Task <IActionResult> Update(Guid id, [FromBody] Account account) { IActionResult result = null; try { if (result == null && account == null) { result = BadRequest("Missing account data"); } if (result == null && string.IsNullOrEmpty(account.Name)) { result = BadRequest("Missing account name"); } if (result == null && Guid.Empty.Equals(id)) { result = BadRequest("Invalid account id"); } if (result == null && !UserCanAccessAccount(id)) { result = StatusCode(StatusCodes.Status401Unauthorized); } if (result == null) { using (ILifetimeScope scope = _container.BeginLifetimeScope()) { SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>(); CoreSettings settings = settingsFactory.CreateAccount(_settings.Value); IAccountFactory accountFactory = scope.Resolve <IAccountFactory>(); IAccount innerAccount = await accountFactory.Get(settings, id); if (innerAccount == null) { result = NotFound(); } else { IMapper mapper = MapperConfigurationFactory.CreateMapper(); mapper.Map <Account, IAccount>(account, innerAccount); IAccountSaver saver = scope.Resolve <IAccountSaver>(); await saver.Update(settings, innerAccount); result = Ok( mapper.Map <Account>(innerAccount) ); } } } } catch (Exception ex) { using (ILifetimeScope scope = _container.BeginLifetimeScope()) { await LogException(ex, scope.Resolve <IExceptionService>(), scope.Resolve <SettingsFactory>(), _settings.Value); } result = StatusCode(StatusCodes.Status500InternalServerError); } return(result); }
public UserService(IUserRepository userRepository, IAccountRepository accountRepository, IUserFactory userFactory, IAccountFactory accountFactory, IJwtProvider jwtProvider) { _userRepository = userRepository; _accountRepository = accountRepository; _userFactory = userFactory; _accountFactory = accountFactory; _jwtProvider = jwtProvider; }
public View(string header, IShell shell, IRepository repo, IAccountFactory factory, ITransferService transferService) { Header = header; Shell = shell; Repository = repo; Factory = factory; TransferService = transferService; }
public AccountService(IEncrypt encryptor, IBus bus, IAccountFactory factory, IFindAccountQuery query, IFailedPasswordQuery failedQuery) { _encryptor = encryptor; _bus = bus; _factory = factory; _query = query; _failedQuery = failedQuery; }
public void SetUp() { _mapStorage.Clear(); _mockAccountFactory = new MockAccountFactory(_mapStorage); WindsorServiceLocator locator=new WindsorServiceLocator(_container=new WindsorContainer()); _container.Register(Component.For(typeof (IAccountFactory)).UsingFactoryMethod(() => _mockAccountFactory)); ServiceLocator.SetLocatorProvider(()=>locator); }
private async Task <string> GetAccountIdClaim(IAccountFactory accountFactory, SettingsFactory settingsFactory, Guid userId) { return(string.Join( ' ', (await accountFactory.GetAccountIdsByUserId(settingsFactory.CreateAccount(_settings.Value), userId)) .Select <Guid, string>(g => g.ToString("N")) )); }
public PaidSheetTransactionReader(IAccountFactory <IPaidRow> accountFactory) : base("Paid") { if (accountFactory == null) { throw new ArgumentNullException("accountFactory"); } _accountFactory = accountFactory; }
public AccountService(IAccountFactory accountFactory, IAccountRepository repository) { if (repository == null || accountFactory == null) { throw new ArgumentNullException("repository", "유효한 저장소 객체를 제공해야 합니다."); } this.accountFactory = accountFactory; this.accountRepository = repository; }
public AccountTreesGardener(IAccountFactory accountFactory, IUserInformator userInformator, IAccountLowLevelOperator accountLowLevelOperator, IAccountCantBeDeletedChecker accountCantBeDeletedChecker, IUserEquirer userEquirer) { _accountFactory = accountFactory; _userInformator = userInformator; _accountLowLevelOperator = accountLowLevelOperator; _accountCantBeDeletedChecker = accountCantBeDeletedChecker; _userEquirer = userEquirer; }
public AccountService(IAccountDataAccessor accountDataAccessor, IAccountSignUpStrategyDataAccessor accountSignUpStrategyDataAccessor, IAccountSignUpService accountSignUpEvaluator, IAccountFactory accountFactory) { _accountDataAccessor = accountDataAccessor; _accountSignUpStrategyDataAccessor = accountSignUpStrategyDataAccessor; _accountSignUpEvaluator = accountSignUpEvaluator; _accountFactory = accountFactory; }
public AccountsService( IRepository repository, IEventBus bus, IMapper <Account, AccountModel> mapper, IAccountFactory factory) { _repository = repository; _bus = bus; _mapper = mapper; _factory = factory; }
/// <summary> /// Initializes a new instance of the <see cref="DepositUseCase" /> class. /// </summary> /// <param name="accountRepository">Account Repository.</param> /// <param name="unitOfWork">Unit Of Work.</param> /// <param name="accountFactory"></param> /// <param name="currencyExchange"></param> public DepositUseCase( IAccountRepository accountRepository, IUnitOfWork unitOfWork, IAccountFactory accountFactory, ICurrencyExchange currencyExchange) { this._accountRepository = accountRepository; this._unitOfWork = unitOfWork; this._accountFactory = accountFactory; this._currencyExchange = currencyExchange; }
public OpenAccountUseCase( IAccountRepository accountRepository, IUnitOfWork unitOfWork, IUserService userService, IAccountFactory accountFactory) { this._accountRepository = accountRepository; this._unitOfWork = unitOfWork; this._userService = userService; this._accountFactory = accountFactory; }
public Deposit( IAccountFactory accountFactory, IOutputPort outputPort, IAccountRepository accountRepository, IUnitOfWork unitOfWork) { _accountFactory = accountFactory; _outputPort = outputPort; _accountRepository = accountRepository; _unitOfWork = unitOfWork; }
public AccountServiceTests() { _accountSignUpStrategyDataAccessor = Substitute.For <IAccountSignUpStrategyDataAccessor>(); _accountDataAccessor = Substitute.For <IAccountDataAccessor>(); _accountSignUpService = Substitute.For <IAccountSignUpService>(); _accountFactory = Substitute.For <IAccountFactory>(); _accountService = new AccountService(_accountDataAccessor, _accountSignUpStrategyDataAccessor, _accountSignUpService, _accountFactory); }
public OpenAccountUseCase( IAccountRepository accountRepository, IUnitOfWork unitOfWork, IUserService userService, IAccountFactory accountFactory) { this._accountRepository = accountRepository; this._unitOfWork = unitOfWork; this._userService = userService; this._accountFactory = accountFactory; this._outputPort = new OpenAccountPresenter(); }
public void SetUp() { PrepareTestDb(); _accountFactory = A.Fake <IAccountFactory>(); _userInformator = A.Fake <IUserInformator>(); _accountLowLevelOperator = A.Fake <IAccountLowLevelOperator>(); _accountCantBeDeletedChecker = A.Fake <IAccountCantBeDeletedChecker>(); _userEquirer = A.Fake <IUserEquirer>(); _underTest = new AccountTreesGardener(_accountFactory, _userInformator, _accountLowLevelOperator, _accountCantBeDeletedChecker, _userEquirer); }
/// <inheritdoc /> public ICredit Deposit(IAccountFactory entityFactory, PositiveMoney amountToDeposit) { if (entityFactory is null) { throw new ArgumentNullException(nameof(entityFactory)); } var credit = entityFactory.NewCredit(this, amountToDeposit, DateTime.UtcNow); this.Credits.Add(credit); return(credit); }
public IDebit Withdraw(IAccountFactory entityFactory, PositiveMoney amountToWithdraw) { if (GetCurrentBalance().LessThan(amountToWithdraw)) { throw new MoneyShouldBePositiveException("Account has not enough funds."); } var debit = entityFactory.NewDebit(this, amountToWithdraw, DateTime.UtcNow); Debits.Add(debit); return(debit); }
public SimpleBankAccountService(IRepository<Account> accountRepositoryProvider, IRepository<User> userRepositoryProvider) { // AccountFactory requires IAccountNumberGenerator in its constructor and therefore requires constructor injection Debug.Assert(ServiceLocator is IServiceLocatorConsructorInjected); IServiceLocatorConsructorInjected injectedLocator = (IServiceLocatorConsructorInjected)ServiceLocator; IAccountNumberGenerator acctNoGenerator = ServiceLocator.Resolve<IAccountNumberGenerator>(); _accountFactory = injectedLocator.Resolve<IAccountFactory>(new ConstructorParameters(acctNoGenerator)); _userRepository = injectedLocator.Resolve<IUserRepository>(new ConstructorParameters(userRepositoryProvider)); _accountRepository = injectedLocator.Resolve<IAccountRepository>(new ConstructorParameters(accountRepositoryProvider)); }
public AccountService(IAccountRepository accountRepository, IAccountFactory accountFactory) { _accountRepository = accountRepository; _accountFactory = accountFactory; }
public void SetUp() { _repository = MockRepository.GenerateMock<IRepository>(); _accountFactory = MockRepository.GenerateMock<IAccountFactory>(); }
public LinkedInAccountProvider(IHttpClient httpClient, IAccountFactory accountFactory) { _httpClient = httpClient; _accountFactory = accountFactory; }
public AccountTests() { this.factory = new AccountFactory(); this.passwordHash = Cryptography.CreateHash(password); }
public Bank(ITransactionFactory transactionFactory, IAccountFactory accountFactory) { throw new System.NotImplementedException(); }
public CustomAuthController(IAccountFactory factory, IAccountRepository repository, IAccountService service) { this.factory = factory; this.repository = repository; this.service = service; }
public AccountService(IAccountFactory accountFactory, IAccountRepository accountRepository) { this.accountFactory = accountFactory; this.accountRepository = accountRepository; }
public UserRepository(IEventStoreClient eventStoreClient, ILoggerFactory loggerFactory, IAccountFactory accountFactory, IAccountContactRefresher accountContactRefresher) : base(eventStoreClient, loggerFactory, "Users") { _accountFactory = accountFactory; _accountContactRefresher = accountContactRefresher; }
public AccountTranslator(IAccountFactory accountFactory) { _accountFactory = accountFactory; }