Exemplo n.º 1
0
 public ExchangeHistoryModel(ExchangeHistory history)
     : base(history)
 {
     if (history != null)
     {
         OptUser_Id = history.OptUser_Id;
         User_Id = history.User_Id;
         Application_Id = history.Application_Id;
         ApplyTime = history.ApplyTime;
         SettlementTime = history.SettlementTime;
         Score = history.Score;
         Money = history.Money;
         Cache = history.Cache;
         Status = history.Status;				
     }
 }
Exemplo n.º 2
0
 public ExchangeHistory AddExchangeHistory(int appid, int userId, string token, ExchangeHistory history)
 {
     try
     {
         CheckToken(appid, userId, token);
         CheckCommand(appid, history.Application_Id, userId, BuiltIns.ExchangeCommand.Id, BuiltIns.AllRole.Id);
         using (TransactionScope scope = new TransactionScope())
         {
             modelAccesser.Add<ExchangeHistory>(history);
             UserApplicationInfo uInfo = new UserApplicationInfo { User_Id = history.User_Id, Application_Id = history.Application_Id };
             modelAccesser.Get<UserApplicationInfo>(uInfo);
             uInfo.Score -= history.Score;
             uInfo.Money -= history.Money;
             modelAccesser.Update<UserApplicationInfo>(uInfo);
             scope.Complete();
         }
         return history;
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Exemplo n.º 3
0
 public void SettlementExchange(int appid, int userId, string token, ExchangeHistory history)
 {
     try
     {
         CheckToken(appid, userId, token);
         CheckCommand(appid, history.Application_Id, userId, BuiltIns.SettlementCommand.Id, BuiltIns.AllRole.Id);
         modelAccesser.Update<ExchangeHistory>(history);
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Exemplo n.º 4
0
 public void ScoreExchange(int appid, int userId, string token, int scoreExchangeAppid, int id, int score, int money)
 {
     try
     {
         CheckToken(appid, userId, token);
         //ToDo: Check everyone can exchange score?
         //CheckCommand(appid, scoreExchangeAppid, userId, BuiltIns.ScoreToMoneyCommand.Id, BuiltIns.AllRole.Id);
         using (TransactionScope scope = new TransactionScope())
         {
             UserApplicationInfo info = new UserApplicationInfo { Application_Id = scoreExchangeAppid, User_Id = id };
             modelAccesser.Get(info);
             if (!info.Score.HasValue || info.Score < score)
             {
                 throw new FaultException<ScoreNotEnoughtException>(new ScoreNotEnoughtException());
             }
             info.Score -= score;
             if (!info.Money.HasValue)
             {
                 info.Money = 0;
             }
             info.Money += money;
             modelAccesser.Update(info);
             ExchangeHistory history = new ExchangeHistory { Application_Id = scoreExchangeAppid, OptUser_Id = userId, User_Id = id, Score = score, Money = money, ApplyTime = DateTime.Now, SettlementTime=DateTime.Now,Status= 2};
             modelAccesser.Add<ExchangeHistory>(history);
             scope.Complete();
         }
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
 public ExchangeHistory AddExchangeHistory(int userId, string token, ExchangeHistory history)
 {
     return client.AddExchangeHistory(application_Id, userId, token, history);
 }
 public void SettlementExchange(int userId, string token, ExchangeHistory history)
 {
     client.SettlementExchange(application_Id, userId, token, history);
 }