public async Task <Wallet> UpdateWalletName(Wallet wallet, string newName) { if (wallet == null) { return(null); } if (!await WalletValidator.Update(wallet, newName)) { return(wallet); } using (UnitOfWork.Begin()) { try { WalletFilter filter = new WalletFilter { UserId = new GuidFilter { Equal = wallet.UserId }, Name = new StringFilter { Equal = wallet.Name } }; wallet = await Get(filter); wallet.Name = newName; await UnitOfWork.WalletRepository.Update(wallet); await UnitOfWork.Commit(); return(await Get(new WalletFilter { Id = new GuidFilter { Equal = wallet.Id }, UserId = new GuidFilter { Equal = wallet.UserId }, Name = new StringFilter { Equal = wallet.Name }, Balance = new DecimalFilter { Equal = wallet.Balance } })); } catch (Exception ex) { await UnitOfWork.Rollback(); wallet.AddError(nameof(WalletService), nameof(wallet.Id), CommonEnum.ErrorCode.SystemError); } } return(wallet); }