public void SaveChanges( EditBankAccountData bankAccountData, byte[] idFrontImage, byte[] idBackImage, byte[] atmCardImage ) { //Server Validation var frontImageId = SaveFile(bankAccountData.IdFrontImage, idFrontImage, bankAccountData.Id); var backImageId = SaveFile(bankAccountData.IdBackImage, idBackImage, bankAccountData.Id); var atmCardImageId = SaveFile(bankAccountData.AtmCardImage, atmCardImage, bankAccountData.Id); using (var scope = CustomTransactionScope.GetTransactionScope()) { var bankAccount = _repository.BankAccounts .Include(x => x.Bank.Brand) .Single(x => x.Id == bankAccountData.Id); bankAccount.Bank = _repository.Banks.Single(x => x.Id == bankAccountData.Bank); bankAccount.CurrencyCode = bankAccountData.Currency; bankAccount.AccountId = bankAccountData.AccountId; bankAccount.AccountName = bankAccountData.AccountName; bankAccount.AccountNumber = bankAccountData.AccountNumber; //bankAccount.AccountType = bankAccountData.AccountType; bankAccount.AccountType = _repository.BankAccountTypes.Single(x => x.Id == bankAccountData.AccountType); bankAccount.Province = bankAccountData.Province; bankAccount.Branch = bankAccountData.Branch; bankAccount.Remarks = bankAccountData.Remarks; bankAccount.SupplierName = bankAccountData.SupplierName; bankAccount.ContactNumber = bankAccountData.ContactNumber; bankAccount.USBCode = bankAccountData.USBCode; bankAccount.PurchasedDate = DateTime.Parse(bankAccountData.PurchasedDate); bankAccount.UtilizationDate = DateTime.Parse(bankAccountData.UtilizationDate); bankAccount.ExpirationDate = DateTime.Parse(bankAccountData.ExpirationDate); //bankAccount.IdFrontImage = frontImageId; //bankAccount.IdBackImage = backImageId; //bankAccount.ATMCardImage = atmCardImageId; bankAccount.Updated = DateTimeOffset.Now.ToBrandOffset(bankAccount.Bank.Brand.TimezoneId); bankAccount.UpdatedBy = _actorInfoProvider.Actor.UserName; if (frontImageId != null) { bankAccount.IdFrontImage = frontImageId; } if (backImageId != null) { bankAccount.IdBackImage = backImageId; } if (atmCardImageId != null) { bankAccount.ATMCardImage = atmCardImageId; } _repository.SaveChanges(); var bankAccountChanged = new BankAccountEdited { Id = bankAccount.Id, AccountId = bankAccount.AccountId, Name = bankAccount.AccountName, Number = bankAccount.AccountNumber, BankId = bankAccount.Bank.Id, UpdatedBy = bankAccount.UpdatedBy, UpdatedDate = bankAccount.Updated.Value, BankAccountStatus = bankAccount.Status, EventCreated = bankAccount.Updated.Value, Remarks = bankAccount.Remarks }; _eventBus.Publish(bankAccountChanged); scope.Complete(); } }