Example #1
0
        public ReportController()
        {
            ViewBag.Today = new DateTime(2018, 4, 16);

            _lectureDataService    = new LectureDataService();
            _lecturerDataService   = new LecturerDataService();
            _attendanceDataService = new AttendanceDataService();
            _groupDataService      = new GroupDataService();
        }
Example #2
0
        private void UpdateAttendance(DateTime date, string cardNumber)
        {
            var currentTime = new DateTime(2018, 4, 16, 14, 27, 52);

            var studentDataService = new StudentDataService();
            var student            = studentDataService.GetByCardNumber(cardNumber);

            var groupDataService = new GroupDataService();
            var group            = groupDataService.GetByStudent(student.Id);

            var lectureDataService = new LectureDataService();
            var lectures           = lectureDataService.GetByGroupId(group.Id);

            var lectureId = -1;

            foreach (var lecture in lectures)
            {
                if (lecture.Occurences.FirstOrDefault(x => x.Date.ToShortDateString() == currentTime.ToShortDateString()) != null &&
                    lecture.LectureTime.LectureStart.AddMinutes(-5).TimeOfDay <= currentTime.TimeOfDay &&
                    lecture.LectureTime.LectureEnd.AddMinutes(5).TimeOfDay >= currentTime.TimeOfDay)
                {
                    lectureId = lecture.Id;
                    break;
                }
            }

            if (lectureId != -1)
            {
                var attendanceDataService = new AttendanceDataService();
                var attendance            = attendanceDataService.GetStudentAttendance(student.Id, lectureId);
                var dateString            = currentTime.ToString("yyyy-MM-dd");

                if (!attendance.AttendedLectures.Contains(dateString))
                {
                    attendance.AttendedLectures += dateString + ",";
                }

                attendanceDataService.UpdateLectures(attendance);
            }
        }
Example #3
0
        // ProcessSwipe handles the workflow for a student swiping their id
        // card at the Learning Factory.

        public String ProcessSwipe(String studentId)
        {
            String message = "";

            StudentDataService    sds = new StudentDataService();
            AttendanceDataService ads = new AttendanceDataService();

            Student student = sds.GetStudent(studentId);

            if (student == null) // new student swipes id card
            {
                String house_assignment = HouseAssignment();
                Console.WriteLine(house_assignment);

                if (sds.CreateStudent(studentId, house_assignment) && ads.CreateAttendance(studentId))
                {
                    message = "Welcome to the Learning Factory! " +
                              "Your house assignment is " + house_assignment +
                              ". Please see our FAQ page if you have questions about this house " +
                              "assignment or the point tracking process.";
                }
                else
                {
                    message = "An error occurred when processing your card. Please try again or " +
                              "find a staff member if error continues to occur.";
                }
            }

            else // existing student swipes id card
            {
                Attendance attendance = ads.GetLatestAttendance(studentId);

                if ((attendance.check_in != null) && (attendance.check_out != null))
                {
                    if (ads.CreateAttendance(studentId))
                    {
                        message = "Hi " + student.first_name + ", you have signed " +
                                  "into the Learning Factory. You currently have "
                                  + student.total_points + " points. Have fun building!";
                    }
                    else
                    {
                        message = "An error occurred when processing your card. Please try again or " +
                                  "find a staff member if error continues to occur.";
                    }
                }

                else
                {
                    if (ads.UpdateSession(attendance.session_id.ToString()))
                    {
                        message = "You have been signed out. You received " +
                                  ads.GetLatestAttendance(studentId).session_points + " points for this visit, " +
                                  " and you have " + sds.GetStudent(studentId).total_points + " points " +
                                  "total. Thanks for coming " + student.first_name + "!";
                    }
                    else
                    {
                        message = "An error occurred when processing your card. Please try again or " +
                                  "find a staff member if error continues to occur.";
                    }
                }
            }
            return(message);
        }