public int CreateWallet(WalletModel wallet) { var walletEntity = new WalletDbRepoModel(); using (_unitOfWork.Add <WalletDbRepoModel>()) { walletEntity = _mapper.Map <WalletDbRepoModel>(wallet); walletEntity.RegistrantId = wallet.RegistrantId; _unitOfWork.GetRepository <WalletDbRepoModel>().AddItem(walletEntity); _unitOfWork.Save(); } return(walletEntity.Id); }
public WalletDbRepoModel GetWalletById(int id, bool includeAccounts = false) { var walletEntity = new WalletDbRepoModel(); using (_unitOfWork.Add <WalletDbRepoModel>().Add <AccountDbRepoModel>()) { if (includeAccounts) { walletEntity = _unitOfWork.GetRepository <WalletDbRepoModel>().Get(wallet => wallet.Id == id, null, "Status").FirstOrDefault(); var accounts = _unitOfWork.GetRepository <AccountDbRepoModel>().Get(account => account.WalletId == walletEntity.Id, null, "Status,CurrencyRelation").ToList(); walletEntity.Accounts = accounts; } else { walletEntity = _unitOfWork.GetRepository <WalletDbRepoModel>().Get(wallet => wallet.Id == id, null, "Status").FirstOrDefault(); } } return(walletEntity); }