public UserDepositHistoryModel(DepositHistory history) : base(history) { if (history != null) { OptUser_Id = history.OptUser_Id; User_Id = history.User_Id; Application_Id = history.Application_Id; Money = history.Money; Time = history.Time; IsAgent = history.IsAgent.HasValue?(history.IsAgent.Value?1:0):0; Score = history.Score; } }
public bool Deposit(int appid, int userId, string token, int depositAppid, int id, int money, bool isAgent) { CheckToken(appid, userId, token); CheckCommand(appid, depositAppid, userId, isAgent ? BuiltIns.AgentDepositCommand.Id : BuiltIns.UserDepositCommand.Id, BuiltIns.AllRole.Id); try { using (TransactionScope scope = new TransactionScope()) { UserApplicationInfo user = new UserApplicationInfo { Application_Id = depositAppid, User_Id = id }; modelAccesser.Get<UserApplicationInfo>(user); if (isAgent) { if (!user.AgentMoney.HasValue) { user.AgentMoney = 0; } user.AgentMoney += money; } else { if (!user.Money.HasValue) { user.Money = 0; } user.Money += money; } modelAccesser.Update<UserApplicationInfo>(user); DepositHistory history = new DepositHistory { Application_Id = depositAppid, IsAgent = isAgent, Money = money, OptUser_Id = userId, User_Id = id, Time = DateTime.Now }; modelAccesser.Add<DepositHistory>(history); scope.Complete(); return true; } } catch { return false; } }
public void ScoreDeposit(int appid, int userId, string token, int depositAppid, int id, int score) { try { CheckToken(appid, userId, token); CheckCommand(appid, depositAppid, userId, BuiltIns.ScoreDepositCommand.Id, BuiltIns.AllRole.Id); using (TransactionScope scope = new TransactionScope()) { UserApplicationInfo info = new UserApplicationInfo { Application_Id = depositAppid, User_Id = id }; modelAccesser.Get(info); if (!info.Score.HasValue) { info.Score = 0; } info.Score += score; modelAccesser.Update(info); DepositHistory history = new DepositHistory { Application_Id = depositAppid, OptUser_Id = userId, User_Id = id, Score = score, Time = DateTime.Now }; modelAccesser.Add<DepositHistory>(history); scope.Complete(); } } catch (Exception) { throw new DatabaseException(); } }