Exemple #1
0
        static RootResponse <DTOAssetInfo> SaveReward(NbManagerEntity manager, string orderId, int coin, int point, int assetType, int tranType, string tranMap)
        {
            var msgCode    = MessageCode.Success;
            int totalCoin  = -1;
            int totalPoint = -1;

            using (var tranMgr = new TransactionManager(Games.NBall.Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main)))
            {
                tranMgr.BeginTransaction();
                do
                {
                    if (coin > 0)
                    {
                        msgCode = ManagerCore.Instance.AddCoinV2(out totalCoin, manager, coin, (int)EnumCoinChargeSourceType.MatchReward, orderId, tranMgr.TransactionObject);
                        if (msgCode != MessageCode.Success)
                        {
                            break;
                        }
                    }
                    if (point > 0)
                    {
                        msgCode = PayCore.Instance.AddBonusV2(out totalPoint, manager.Account, point, EnumChargeSourceType.MatchReward, orderId, tranMgr.TransactionObject);
                        if (msgCode != MessageCode.Success)
                        {
                            break;
                        }
                    }
                    int errorCode = 0;
                    NbManagerMgr.AssetRecord(false, manager.Idx, assetType, tranType, tranMap, ref errorCode, tranMgr.TransactionObject);
                    msgCode = (MessageCode)errorCode;
                }while (false);
                if (msgCode != MessageCode.Success)
                {
                    tranMgr.Rollback();
                    return(ResponseHelper.CreateRoot <DTOAssetInfo>(msgCode));
                }
                tranMgr.Commit();
            }
            ManagerCore.Instance.DeleteCache(manager.Idx);
            var data = new DTOAssetInfo(totalCoin, totalPoint);

            return(ResponseHelper.CreateRoot <DTOAssetInfo>(data));
        }