Ejemplo n.º 1
0
        /// <summary>
        ///批量更新
        /// </summary>
        /// <returns>Task&lt;List&lt;Enterprise&gt;&gt;.</returns>
        public static async Task <bool> UpdateDbByAssetIdAsync(DraftBill draftBill, Asset asset, EnterpriseLoan enterpriseLoan, FinancierPlayMoney financierPlayMoney, FinancierReturnedMoney financierReturnedMoney, FinancierReturnedMoneyDetail financierReturnedMoneyDetail, InvestProjectAsset investProjectAsset, MerchantBill merchantBill, PeerToPeer peerToPeer, PlayMoneyBodyMessage playMoneyBodyMessage, ProductAsset productAsset, UserReturnedMoney userReturnedMoney)
        {
            using (AssetDbContext context = new AssetDbContext())
            {
                using (var tran = context.Database.BeginTransaction())
                {
                    if (draftBill != null)
                    {
                        context.DraftBills.AddOrUpdate(draftBill);
                    }
                    if (asset != null)
                    {
                        context.Assets.AddOrUpdate(asset);
                    }
                    if (enterpriseLoan != null)
                    {
                        context.EnterpriseLoans.AddOrUpdate(enterpriseLoan);
                    }
                    if (financierPlayMoney != null)
                    {
                        context.FinancierPlayMoneys.AddOrUpdate(financierPlayMoney);
                    }
                    if (financierReturnedMoney != null)
                    {
                        context.FinancierReturnedMoneys.AddOrUpdate(financierReturnedMoney);
                    }
                    if (financierReturnedMoneyDetail != null)
                    {
                        context.FinancierReturnedMoneyDetails.AddOrUpdate(financierReturnedMoneyDetail);
                    }
                    if (investProjectAsset != null)
                    {
                        context.InvestProjectAssets.AddOrUpdate(investProjectAsset);
                    }
                    if (merchantBill != null)
                    {
                        context.MerchantBills.AddOrUpdate(merchantBill);
                    }
                    if (peerToPeer != null)
                    {
                        context.PeerToPeers.AddOrUpdate(peerToPeer);
                    }
                    if (playMoneyBodyMessage != null)
                    {
                        context.PlayMoneyBodyMessages.AddOrUpdate(playMoneyBodyMessage);
                    }
                    if (productAsset != null)
                    {
                        context.ProductAssets.AddOrUpdate(productAsset);
                    }
                    if (userReturnedMoney != null)
                    {
                        context.UserReturnedMoneys.AddOrUpdate(userReturnedMoney);
                    }
                    var result = await context.SaveChangesAsync() > 0;

                    if (result)
                    {
                        tran.Commit();
                    }
                    return(result);
                }
            }
        }