public Guid Add(AddBankData data) { var validationResult = _bankQueries.ValidateCanAdd(data); if (!validationResult.IsValid) throw new RegoValidationException(validationResult); var bank = Mapper.Map<AFT.RegoV2.Core.Payment.Data.Bank>(data); bank.Id = data.Id ?? Guid.NewGuid(); bank.Created = DateTime.Now; bank.CreatedBy = _actorInfoProvider.Actor.UserName; using (var scope = CustomTransactionScope.GetTransactionScope()) { _repository.Banks.Add(bank); _repository.SaveChanges(); var bankAdded = new BankAdded { Id = bank.Id, BankId = bank.BankId, BrandId = bank.BrandId, Name = bank.BankName, CreatedDate = bank.Created }; _eventBus.Publish(bankAdded); scope.Complete(); } return bank.Id; }
public ValidationResult ValidateCanAdd(AddBankData data) { return(new AddBankValidator(_paymentRepository).Validate(data)); }