Esempio n. 1
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);
        }
Esempio n. 2
0
        private void InsertStudent()
        {
            DialogService      dialogservice = new DialogService();
            var                picker        = geboortedatum;
            StudentDataService ds            = new StudentDataService();
            Student            nieuweStudent = new Student();

            nieuweStudent.Achternaam     = achternaam;
            nieuweStudent.Voornaam       = voornaam;
            nieuweStudent.Klas           = klas;
            nieuweStudent.Geboortedatum  = picker.Date;
            nieuweStudent.Geslacht       = geslacht;
            nieuweStudent.TelefoonNummer = telefoonNummer;
            nieuweStudent.EmailAdres     = emailAdres;

            Student bestaandeStudent = new Student();

            bestaandeStudent = ds.GetStudent(nieuweStudent.Voornaam, nieuweStudent.Achternaam);

            if (bestaandeStudent != null)
            {
                if (nieuweStudent.Voornaam == bestaandeStudent.Voornaam && nieuweStudent.Achternaam == bestaandeStudent.Achternaam && picker.Date.Year > 1900 && picker.Date < DateTime.Now)
                {
                    MessageBoxResult resultaat = MessageBox.Show(
                        "Een student met deze naam is al gevonden in het systeem, bent u zeker dat u deze student wilt aanmaken ?",
                        "Dubbel gevonden", MessageBoxButton.YesNo);

                    if (resultaat == MessageBoxResult.Yes)
                    {
                        ds.InsertStudent(nieuweStudent);
                    }
                }
                else
                {
                    if (picker.Date.Year > 1900 && picker.Date < DateTime.Now)
                    {
                        ds.InsertStudent(nieuweStudent);
                    }
                    else
                    {
                        MessageBox.Show(
                            "U probeert een student aan te maken met een ongeldige geboortedatum, probeer nog eens",
                            "Ongeldige geboortedatum", MessageBoxButton.OK);
                    }
                }
            }
            else
            {
                if (picker.Date.Year > 1900 && picker.Date < DateTime.Now)
                {
                    ds.InsertStudent(nieuweStudent);
                }
                else
                {
                    MessageBox.Show(
                        "U probeert een student aan te maken met een ongeldige geboortedatum, probeer nog eens",
                        "Ongeldige geboortedatum", MessageBoxButton.OK);
                }
            }
            Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage("Completed"));
        }