示例#1
0
        public void UpdateForOutTime(int id)
        {
            AttendanceOfStudent attendanceOfStudent = _context.AttendanceOfStudent.Find(id);

            attendanceOfStudent.OutTime = DateTime.UtcNow.AddHours(6).TimeOfDay;
            _context.AttendanceOfStudent.Update(attendanceOfStudent);
            _context.SaveChanges();
        }
示例#2
0
        public int SaveAttendance(int studentId)
        {
            TimeSpan            time = DateTime.UtcNow.AddHours(6).TimeOfDay;
            AttendanceOfStudent attendanceOfStudent = _context.AttendanceOfStudent.Where(ta => ta.StudentId == studentId && ta.Date == DateTime.UtcNow.AddHours(6).Date).FirstOrDefault();

            if (attendanceOfStudent == null)
            {
                AttendanceOfStudent NewAttendanceOfStudent = new AttendanceOfStudent {
                    StudentId = studentId, Date = DateTime.UtcNow.AddHours(6).Date, InTime = time, OutTime = time
                };
                _context.AttendanceOfStudent.Add(NewAttendanceOfStudent);
                _context.SaveChanges();
                return(1);
            }
            return(0);
        }