コード例 #1
0
 public PunchCard PurchasePunchCard(PunchCard punchCard)
 {
     punchCard.CurrentMemberID = punchCard.PurchaseMemberID;
     _dbContext.PunchCards.Add(punchCard);
     _dbContext.SaveChanges();
     return(punchCard);
 }
コード例 #2
0
 public void DeletePunchCard(PunchCard punchCard)
 {
     if (PunchCardExists(punchCard.PunchCardID) &&
         punchCard.RemainingPunches == 5)
     {
         _dbContext.PunchCards.Remove(punchCard);
         _dbContext.SaveChanges();
     }
 }
コード例 #3
0
 public Attendance AddAttendance(Attendance attendance, PunchCard punchCard)
 {
     _dbContext.Attendances.Add(attendance);
     _dbContext.SaveChanges();
     _dbContext.PunchCardUsages.Add(new PunchCardUsage
     {
         AttendanceID = attendance.AttendanceID,
         PunchCardID  = punchCard.PunchCardID
     });
     _dbContext.SaveChanges();
     return(attendance);
 }
コード例 #4
0
 public PunchCard TransferPunchCard(PunchCard punchCard)
 {
     _dbContext.Attach(punchCard).State = EntityState.Modified;
     try {
         _dbContext.SaveChanges();
     }
     catch (DbUpdateConcurrencyException) {
         if (!PunchCardExists(punchCard.PunchCardID))
         {
             return(null);
         }
         else
         {
             throw;
         }
     }
     return(punchCard);
 }