コード例 #1
0
 public static Boolean StudentClockIn(int studentID, int classID)
 {
     if (IsValidStudentID(studentID) && CheckClass(studentID, classID) && CheckClockTime(DateTime.Now, studentID))
     {
          
         if (IsClockedIn(studentID, classID))
         {
             EFClock clock = schoolData.EFClocks.Where(c => c.StudentID == studentID && c.ClockedIn == true).Single();
             clock.EndTime = DateTime.Now;
             clock.ClockedIn = false;
             clock.Absence = CheckClockTime(DateTime.Now, studentID) ? true : false;
         }
         else
         {
             EFClock clock = new EFClock();
             clock.StudentID = studentID;
             clock.ClassID = classID;
             clock.StartTime = DateTime.Now;
             clock.ClockedIn = true;
             clock.Absence = CheckClockTime(DateTime.Now, studentID) ? true : false;
             schoolData.EFClocks.Add(clock);
         }
         schoolData.SaveChanges();
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #2
0
 public static Boolean StudentClockIn(int studentID, int classID)
 {
     if (IsValidStudentID(studentID) && CheckClass(studentID, classID) && CheckClockTime(DateTime.Now, studentID))
     {
         if (IsClockedIn(studentID, classID))
         {
             EFClock clock = schoolData.EFClocks.Where(c => c.StudentID == studentID && c.ClockedIn == true).Single();
             clock.EndTime   = DateTime.Now;
             clock.ClockedIn = false;
             clock.Absence   = CheckClockTime(DateTime.Now, studentID) ? true : false;
         }
         else
         {
             EFClock clock = new EFClock();
             clock.StudentID = studentID;
             clock.ClassID   = classID;
             clock.StartTime = DateTime.Now;
             clock.ClockedIn = true;
             clock.Absence   = CheckClockTime(DateTime.Now, studentID) ? true : false;
             schoolData.EFClocks.Add(clock);
         }
         schoolData.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }