public void Edit(EditBankData data) { var validationResult = _bankQueries.ValidateCanEdit(data); if (!validationResult.IsValid) throw new RegoValidationException(validationResult); using (var scope = CustomTransactionScope.GetTransactionScope()) { var bank = _repository.Banks.Single(x => x.Id == data.Id); bank = Mapper.Map(data, bank); bank.Updated = DateTime.Now; bank.UpdatedBy = _actorInfoProvider.Actor.UserName; _repository.SaveChanges(); var bankAdded = new BankEdited { Id = bank.Id, BankId = bank.BankId, BankName = bank.BankName, BrandId = bank.BrandId, UpdatedDate = bank.Updated.GetValueOrDefault() }; _eventBus.Publish(bankAdded); scope.Complete(); } }
public SaveBankResponse Edit(EditBankRequest request) { VerifyPermission(Permissions.Update, Modules.Banks); CheckBrand(request.BrandId); var data = Mapper.Map <Core.Payment.Interface.Data.Commands.EditBankData>(request); var validationResult = _bankQueries.ValidateCanEdit(data); if (!validationResult.IsValid) { return(ValidationErrorResponse <SaveBankResponse>(validationResult)); } _bankCommands.Edit(data); return(new SaveBankResponse { Success = true }); }