public PunchCard PurchasePunchCard(PunchCard punchCard) { punchCard.CurrentMemberID = punchCard.PurchaseMemberID; _dbContext.PunchCards.Add(punchCard); _dbContext.SaveChanges(); return(punchCard); }
public void DeletePunchCard(PunchCard punchCard) { if (PunchCardExists(punchCard.PunchCardID) && punchCard.RemainingPunches == 5) { _dbContext.PunchCards.Remove(punchCard); _dbContext.SaveChanges(); } }
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); }
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); }