예제 #1
0
 public EntityService(
     IFactory factory,
     stagemanagerEntities entities)
 {
     this.factory = factory;
     this.entities = entities;
 }
예제 #2
0
        public AppBootstrapper()
            : base()
        {
            windowManager = new WindowManager();

            smEntities = new stagemanagerEntities();

            LoginViewModel loginViewModel = new LoginViewModel();

            // Show Window
            windowManager.ShowWindow(loginViewModel);
        }
예제 #3
0
 public Wrapper()
 {
     if (timer == null)
     {
         timer = new DispatcherTimer();
         time = new TimeSpan(0, 0, 1);
         timer.Interval = time;
         timer.Tick += timer_Tick;
     }
     if (stageManagerEntities == null)
     {
         stageManagerEntities = new stagemanagerEntities();
     }
 }
예제 #4
0
        public AppBootstrapper()
            : base()
        {
            windowManager = new WindowManager();
            defaultFactory = new DefaultFactory();
            smEntities = new stagemanagerEntities();

            entityService = new EntityService(defaultFactory, smEntities);
            viewController = new ViewController();

            // Observer observable
            MainViewModel mainViewModel = new MainViewModel();
            mainViewModel.SomethingHappened += viewController.HandleEvent;

            // Show Window
            windowManager.ShowWindow(mainViewModel);
        }
예제 #5
0
        public administrators Connect(String username, String password)
        {
            try
            {
                if (username != null && password != null)
                {
                    System.Diagnostics.Debug.WriteLine("Connect");
                    stagemanagerEntities smE = new stagemanagerEntities();
                    administrators user = null;

                    List<administrators> admins = smE.administrators.ToList();
                    for (int i = 0; i < admins.Count; i++)
                    {
                        if (admins[i].users.email == username && admins[i].password == password)
                        {
                            user = admins[i];
                        }
                    }

                    if (user != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Logged in as " + user.users.name + " " + user.users.surname);
                        return user;
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Invalid Username or Password");
                        return null;
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Invalid Stuff");
                    return null;
                }
            }
            catch (Exception)
            {
                return null;
            }
        }
        private void refresh()
        {
            stagemanagerEntities smE = new stagemanagerEntities();
            List<students> students = smE.students.ToList();
            List = new Dictionary<object, students>();
            List = students.ToDictionary(t => (Object)new
            {
                MailTo = false,
                Email = t.users != null ? t.users.email : "student heeft geen gebruiker",
                Student = t.users != null ? t.users.name + " " + t.users.surname : "student heeft geen gebruiker",
                Gegevens = t.users != null || t.students_internships != null || t.students_internships.Count > 0 ? "Compleet" : "Niet compleet",
                Stageopdracht = t.students_internships != null && t.students_internships.Count > 0 ? t.students_internships.First().internships.description : "niet ingeleverd",
                Goedgekeurd = t.students_internships != null && t.students_internships.Count > 0 ?
                    (t.students_internships.First().internships.approved == "0" ?
                        "In afwachting" :
                        (t.students_internships.First().internships.approved == "1" ?
                            "Goedgekeurd" :
                            (t.students_internships.First().internships.approved == "2" ?
                                "Wordt nagekeken" :
                                (t.students_internships.First().internships.approved == "3" ?
                                    "Niet goedgekeurd" :
                                    "fout in db"
                                )
                            )
                        )
                    ) :
                    "niet van toepassing"
            }, t => t);

            // Haal ook alle lege webkeys mee
            foreach (webkeys w in new WStored().SearchWebkeys())
            {
                if (w.user_id == null)
                {
                    Object o = (Object)new
                    {
                        MailTo = false,
                        Email = w.email != null ? w.email : "student heeft geen gebruiker",
                        Student = "Nog niet ingevuld",
                        Stageopdracht = "niet van toepassing",
                        Gegevens = "niet van toepassing",
                        Goedgekeurd = "niet van toepassing"
                    };
                    try
                    {
                        list.Add(o, null);
                    }
                    catch (Exception)
                    { }
                }
            }
            List = List;
        }
        public void updateStageStatus()
        {
            stagemanagerEntities smE = new stagemanagerEntities();
            List<students> students = smE.students.ToList();

            for (int i = 0; i < List.Keys.Count; i++)
            {

                if ((bool)List.Keys.ElementAt(i).GetType().GetProperty("MailTo").GetMethod.Invoke(List.Keys.ElementAt(i), null))
                {
                    students s;
                    List.TryGetValue(List.Keys.ElementAt(i), out s);

                    if (s == null)
                        return;

                    try
                    {
                        switch (s.students_internships.First().internships.approved)
                        {
                            case "0":
                                s.students_internships.First().internships.approved = "2";
                                break;

                            case "1":
                                s.students_internships.First().internships.approved = "3";
                                break;

                            case "2":
                                s.students_internships.First().internships.approved = "1";
                                break;

                            case "3":
                                s.students_internships.First().internships.approved = "0";
                                break;

                        }
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("Kan niet");
                    }

                    foreach (students st in students)
                    {
                        if (s.users.email == st.users.email)
                        {
                            if (st.students_internships.Count > 0)
                            {
                                st.students_internships.First().internships.approved = s.students_internships.First().internships.approved;
                            }
                        }
                    }
                }
            }
            smE.SaveChanges();
            refresh();
        }
        public void MailStageSelectie()
        {
            String stageData = "";
            List<String> mails = new List<string>();
            for (int i = 0; i < List.Keys.Count; i++)
            {
                if ((bool)List.Keys.ElementAt(i).GetType().GetProperty("MailTo").GetMethod.Invoke(List.Keys.ElementAt(i), null))
                {
                    students s;
                    List.TryGetValue(List.Keys.ElementAt(i), out s);
                    stageData = s.students_internships.First().internships.description + "\n Van " + s.students_internships.First().internships.start_date + " Tot " + s.students_internships.First().internships.end_date;

                    stagemanagerEntities smE = new stagemanagerEntities();
                    List<students> students = smE.students.ToList();

                    foreach (students st in students)
                    {
                        if (s.users.email == st.users.email)
                        {
                            if (st.students_internships.Count > 0)
                            {
                                st.students_internships.First().internships.approved = "2";
                            }
                        }
                    }
                    smE.SaveChanges();
                }
            }

            Main.ChangeButton("Mail", this, new List<object>() { mails, MailViewModel.mailType.beoordeling, stageData }, Clear.No);
        }
예제 #9
0
        private String decideWindowState()
        {
            String windowToOpen = "Mail";

            stagemanagerEntities smE = new stagemanagerEntities();
            List<students> students = smE.students.ToList();

            for (int i = 0; i < students.Count; i++)
            {
                if (students[i].students_internships.ToList().Count == 0 || students[i].students_internships.First().internships == null || students[i].students_internships.First().internships.teachers == null)
                {
                    windowToOpen = "ProcesOverzicht";
                }
            }

            return windowToOpen;
        }
        public GegevensOverzichtViewModel(MainViewModel main, PropertyChanged last)
            : base(main, last)
        {
            stagemanagerEntities smE = new stagemanagerEntities();
            List<students> students = smE.students.ToList();
            List = new Dictionary<object, students>();
            List<students> studenten = new List<students>();

            for (int i = 0; i < students.Count; i++)
            {
                users thisUser = new users
                {
                    name = "",
                    surname = "",
                    phonenumber = "",
                    email = "",
                };

                adresses thisAdresses = new adresses
                {
                    street = "",
                    housenumber = "",
                    place = "",
                    zipcode = "",
                };

                adresses companyAdresses = new adresses
                {
                    street = "",
                    housenumber = "",
                    place = "",
                    zipcode = "",
                };

                companies thisCompany = new companies
                {
                     name ="",
                     website = "",
                     phonenumber = "",
                     adresses = companyAdresses
                };

                users superviserUser = new users
                {
                    name = "",
                    surname = "",
                    phonenumber = "",
                    email = "",
                };

                supervisor thisSupervisor = new supervisor
                {
                    users = superviserUser,
                    companies = thisCompany
                };

                List<students_internships> myList = new List<students_internships>();
                myList.Add(new students_internships
                {
                internships = new internships
                        {
                            supervisor = thisSupervisor
                        }
                    });

                students thisStudent = new students
                {
                    users = thisUser,
                    meets = "",
                    adresses = thisAdresses,
                    studentnumber = 0,
                    students_internships = myList
                };

                if (students[i].studentnumber != null)
                {
                    thisStudent.studentnumber = students[i].studentnumber;
                }

                if (students[i].meets != null)
                {
                            thisStudent.meets = students[i].meets;
                }

                if (students[i].users == null)
                {
                }
                else
                {
                    if (students[i].users.name != null)
                    {

                        thisStudent.users.name = students[i].users.name;
                    }

                    if (students[i].users.surname != null)
                    {
                        thisStudent.users.surname = students[i].users.surname;
                    }

                    if (students[i].users.email != null)
                    {
                        thisStudent.users.email = students[i].users.email;
                    }

                    if (students[i].users.phonenumber != null)
                    {
                        thisStudent.users.phonenumber = students[i].users.phonenumber;
                    }
                }

                if (students[i].adresses == null)
                {
                    thisStudent.adresses.street = "";
                    thisStudent.adresses.housenumber = "";
                    thisStudent.adresses.zipcode = "";
                    thisStudent.adresses.place = "";
                }
                else
                {
                    if (students[i].adresses.street != null)
                    {
                        thisStudent.adresses.street = students[i].adresses.street;
                    }

                    if (students[i].adresses.housenumber != null)
                    {
                        thisStudent.adresses.housenumber = students[i].adresses.housenumber;
                    }

                    if (students[i].adresses.zipcode != null)
                    {
                        thisStudent.adresses.zipcode = students[i].adresses.zipcode;
                    }

                    if (students[i].adresses.place != null)
                    {
                        thisStudent.adresses.place = students[i].adresses.place;
                    }
                }

                if (students[i].students_internships != null && students[i].students_internships.Count > 0 && students[i].students_internships.First().internships != null)
                {

                    if (students[i].students_internships.First().internships.supervisor != null)
                    {
                        if (students[i].students_internships.First().internships.supervisor.users.name != null)
                        {
                            thisStudent.students_internships.First().internships.supervisor.users.name = students[i].students_internships.First().internships.supervisor.users.name;
                        }

                        if (students[i].students_internships.First().internships.supervisor.users.phonenumber != null)
                        {
                            thisStudent.students_internships.First().internships.supervisor.users.phonenumber = students[i].students_internships.First().internships.supervisor.users.phonenumber;
                        }

                        if (students[i].students_internships.First().internships.supervisor.companies != null)
                        {
                            if (students[i].students_internships.First().internships.supervisor.companies.name != null)
                            {
                                thisStudent.students_internships.First().internships.supervisor.companies.name = students[i].students_internships.First().internships.supervisor.companies.name;
                            }

                            if (students[i].students_internships.First().internships.supervisor.companies.phonenumber != null)
                            {
                                thisStudent.students_internships.First().internships.supervisor.companies.phonenumber = students[i].students_internships.First().internships.supervisor.companies.phonenumber;
                            }

                            if (thisStudent.students_internships.First().internships.supervisor.companies.adresses != null)
                            {
                                if (students[i].students_internships.First().internships.supervisor.companies.adresses.street != null)
                                {
                                    thisStudent.students_internships.First().internships.supervisor.companies.adresses.street = students[i].students_internships.First().internships.supervisor.companies.adresses.street;
                                }

                                if (students[i].students_internships.First().internships.supervisor.companies.adresses.housenumber != null)
                                {
                                    thisStudent.students_internships.First().internships.supervisor.companies.adresses.housenumber = students[i].students_internships.First().internships.supervisor.companies.adresses.housenumber;
                                }

                                if (students[i].students_internships.First().internships.supervisor.companies.adresses.zipcode != null)
                                {
                                    thisStudent.students_internships.First().internships.supervisor.companies.adresses.zipcode = students[i].students_internships.First().internships.supervisor.companies.adresses.zipcode;
                                }

                                if (students[i].students_internships.First().internships.supervisor.companies.adresses.place != null)
                                {
                                    thisStudent.students_internships.First().internships.supervisor.companies.adresses.place = students[i].students_internships.First().internships.supervisor.companies.adresses.place;
                                }
                            }

                            if (students[i].students_internships.First().internships.supervisor.companies.phonenumber != null)
                            {
                                thisStudent.students_internships.First().internships.supervisor.companies.phonenumber = students[i].students_internships.First().internships.supervisor.companies.phonenumber;
                            }

                            if (students[i].students_internships.First().internships.supervisor.companies.website != null)
                            {
                                thisStudent.students_internships.First().internships.supervisor.companies.website = students[i].students_internships.First().internships.supervisor.companies.website;
                            }
                        }
                    }
                }

                studenten.Add(thisStudent);

            }

            List = studenten.ToDictionary(t => (Object)new
            {
                Studentnummer = t.studentnumber,
                Voornaam = t.users.name,
                Achternaam = t.users.surname,
                Email = t.users.email,
                EmailURL = t.users.email,
                Telefoonnummer = t.users.phonenumber,
                ToestEx = t.meets,
                Straatnaam = t.adresses.street,
                Nummer = t.adresses.housenumber,
                Postcode = t.adresses.zipcode,
                Plaats = t.adresses.place,
                Bedrijf = t.students_internships.First().internships.supervisor.companies.name,
                BTelefoon = t.students_internships.First().internships.supervisor.companies.phonenumber,
                Website = t.students_internships.First().internships.supervisor.companies.website,
                BStraat = t.students_internships.First().internships.supervisor.companies.adresses.street,
                BNummer = t.students_internships.First().internships.supervisor.companies.adresses.housenumber,
                BPostcode = t.students_internships.First().internships.supervisor.companies.adresses.zipcode,
                BPlaats = t.students_internships.First().internships.supervisor.companies.adresses.place,
                Bedrijfsbegeleider = t.students_internships.First().internships.supervisor.users.name + " " + t.students_internships.First().internships.supervisor.users.surname,
                BegTelefoon = t.students_internships.First().internships.supervisor.users.phonenumber
            }, t => t);
        }