Beispiel #1
0
 /// <summary>
 ///     还书后根据借阅 ID 查询是否超期,若超期则扣信用分
 /// </summary>
 /// <param name="borrowId"></param>
 public void ReturnResult(int borrowId)
 {
     try
     {
         GlobalFunc.RefreshBookState();
         var state = DbContext.DBstatic.Queryable <Borrows>()
                     .Where(br => br.Borrow_id == borrowId)
                     .Select(br => br.State)
                     .First();
         if (state == -1)
         {
             var userId = DbContext.DBstatic.Queryable <Borrows>()
                          .Where(br => br.Borrow_id == borrowId)
                          .Select(rd => rd.Reader_id)
                          .First();
             var score = DbContext.DBstatic.Queryable <ReaderInfo>()
                         .Where(rd => rd.ID == userId)
                         .Select(rd => rd.Credit_Score)
                         .First();
             var setScore = score - 30;
             if (setScore < 0)
             {
                 setScore = 0;
             }
             DbContext.DBstatic.Updateable <Reader>()
             .SetColumns(rd => new Reader
             {
                 credit_score = setScore
             })
             .Where(rd => rd.id == userId)
             .ExecuteCommand();
         }
     }
     catch
     {
         throw new Exception("Credit modification failed");
     }
 }
Beispiel #2
0
 public void Do()
 {
     GlobalFunc.RefreshBookState();
 }