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 SaveBankResponse Add(AddBankRequest request) { VerifyPermission(Permissions.Create, Modules.Banks); CheckBrand(request.BrandId); var data = Mapper.Map <Core.Payment.Interface.Data.Commands.AddBankData>(request); var validationResult = _bankQueries.ValidateCanAdd(data); if (!validationResult.IsValid) { return(ValidationErrorResponse <SaveBankResponse>(validationResult)); } var bankId = _bankCommands.Add(data); return(new SaveBankResponse { Success = true, Id = bankId }); }