Example #1
0
        MessageCode Tran_SaveAttachment(DbTransaction transaction, List <MailInfoEntity> mails, ItemPackageFrame package, NbManagerEntity manager, int coin, int sophicate, int point, int prestige, int bindPoint, int addGoldBar, Guid managerId, int addluckyCoin, int addGameCoin)
        {
            var orderId = mails[0].Idx.ToString();

            foreach (var mail in mails)
            {
                if (!MailInfoMgr.Update(mail, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (package != null)
            {
                if (!package.Save(transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            if (coin > 0)
            {
                var code = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.MailAttachment, orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (sophicate > 0)
            {
                int resultSophisticate = manager.Sophisticate;
                if (!NbManagerMgr.AddSophisticate(manager.Idx, sophicate, ref resultSophisticate, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (point > 0)
            {
                var code = PayCore.Instance.AddBonus(manager.Account, point, EnumChargeSourceType.MailAttachment,
                                                     orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (bindPoint > 0)
            {
                var payUser = PayUserMgr.GetById(manager.Account);
                if (payUser == null)
                {
                    payUser           = new PayUserEntity();
                    payUser.Account   = manager.Account;
                    payUser.BindPoint = bindPoint;
                    payUser.RowTime   = DateTime.Now;
                    payUser.IsNew     = true;
                }
                else
                {
                    payUser.BindPoint += bindPoint;
                }
                if (payUser.IsNew)
                {
                    if (!PayUserMgr.Insert(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    if (!PayUserMgr.Update(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
            }
            if (addGoldBar > 0)
            {
                var goldBarManager = ScoutingGoldbarMgr.GetById(managerId);
                if (goldBarManager == null)
                {
                    goldBarManager = new ScoutingGoldbarEntity(managerId, addGoldBar, 0, 0, 0, DateTime.Now,
                                                               DateTime.Now);
                    if (!ScoutingGoldbarMgr.Insert(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + addGoldBar;
                    if (!ScoutingGoldbarMgr.Update(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                GoldbarRecordEntity record = new GoldbarRecordEntity(0, managerId, true, addGoldBar, (int)EnumCoinChargeSourceType.MailAttachment, DateTime.Now);
                GoldbarRecordMgr.Insert(record);
            }
            if (addluckyCoin > 0)
            {
                if (!TurntableManagerMgr.AddLuckyCoin(managerId, addluckyCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (addGameCoin > 0)
            {
                if (!PenaltykickManagerMgr.AddGameCurrency(managerId, addGameCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            return(MessageCode.Success);
        }