public long Add(CheckingAccountRegisterCommand cmd) { var checkingAccount = Mapper.Map <CheckingAccountRegisterCommand, CheckingAccount>(cmd); checkingAccount.Client = _clientRepository.GetById(cmd.Client.Id) ?? throw new NotFoundException(); var newCheckingAccount = _checkingAccountRepository.Add(checkingAccount); return(checkingAccount.Id); }
public IHttpActionResult Post(CheckingAccountRegisterCommand cmd) { var validator = cmd.Validate(); if (!validator.IsValid) { return(HandleValidationFailure(validator.Errors)); } return(HandleCallback(() => _accountsService.Add(cmd))); }
public void SetUp() { AutoMapperInitializer.Reset(); AutoMapperInitializer.Initialize(); _checkingAccount = ObjectMother.GetCheckingAccountValid(); _checkingAccountRegister = Mapper.Map <CheckingAccountRegisterCommand>(_checkingAccount); _checkingAccountUpdate = Mapper.Map <CheckingAccountUpdateCommand>(_checkingAccount); _checkingAccountRemove = Mapper.Map <CheckingAccountRemoveCommand>(_checkingAccount); _mockRepositoryAccount = new Mock <ICheckingAccountRepository>(); _mockRepositoryClient = new Mock <IClientRepository>(); _service = new CheckingAccountService(_mockRepositoryAccount.Object, _mockRepositoryClient.Object); }