public ActionResult DeleteConfirmed(int id)
        {
            SchoolTeacher schoolTeacher = db.Schoolteachers.Find(id);

            db.Schoolteachers.Remove(schoolTeacher);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Age,Salary,FirstName,LastName,Position")] SchoolTeacher schoolTeacher)
 {
     if (ModelState.IsValid)
     {
         db.Entry(schoolTeacher).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(schoolTeacher));
 }
        public ActionResult Create([Bind(Include = "Id,Age,Salary,FirstName,LastName,Position")] SchoolTeacher schoolTeacher)
        {
            if (ModelState.IsValid)
            {
                db.Schoolteachers.Add(schoolTeacher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(schoolTeacher));
        }
示例#4
0
 private void ContextMenuCopyButton_Click(object sender, RoutedEventArgs e)
 {
     if (TeachersList.SelectedItems != null)
     {
         foreach (SchoolTeacher item in TeachersList.SelectedItems)
         {
             var teacher = new SchoolTeacher(item.Name, item.Post, item.Experience, item.Address, item.Telephone);
             SchoolTeacherDict.dictionaryList.Add(teacher);
             TeachersList.Items.Add(teacher);
         }
     }
 }
示例#5
0
 public void Add_Click(object sender, RoutedEventArgs e)
 {
     if (!IsWrongTextBoxValue())
     {
         var OwnerWindowInstance = this.Owner as TeachersWindow;
         var teacher             = new SchoolTeacher(NameTextBox.Text, PostTextBox.Text, int.Parse(ExperienceTextBox.Text), AddressTextBox.Text, TelephoneTextBox.Text);
         OwnerWindowInstance.SchoolTeacherDict.dictionaryList.Add(teacher);
         OwnerWindowInstance.TeachersList.Items.Add(teacher);
         ((Owner as TeachersWindow).Owner as EditorWindow).HomePage.TeachersIndicator.Fill = ColorPalette.GetPredefinedColor(PredefinedColors.Green);
         ElementsModification.ResetControlText <TextBox>(this);
     }
 }
        // GET: SchoolTeachers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SchoolTeacher schoolTeacher = db.Schoolteachers.Find(id);

            if (schoolTeacher == null)
            {
                return(HttpNotFound());
            }
            return(View(schoolTeacher));
        }
示例#7
0
        private void ImportExcel_Click(object sender, RoutedEventArgs e)
        {
            string[,] data = ExcelFileTools.UploadExcelData();
            if (data?.GetLength(1) >= ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2)
            {
                for (int i = 0; i < data.GetLength(0); i++)
                {
                    int.TryParse(data[i, 2], out int exp);

                    var teacher = new SchoolTeacher(data[i, 0], data[i, 1], exp, data[i, 3], data[i, 4]);
                    SchoolTeacherDict.dictionaryList.Add(teacher);
                    TeachersList.Items.Add(teacher);
                }
                (Owner as EditorWindow).HomePage.TeachersIndicator.Fill = ColorPalette.GetPredefinedColor(PredefinedColors.Green);
            }
            else if (data?.GetLength(1) < ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2)
            {
                MessageBox.Show("Wrong Columns Format");
            }
        }
 public SchoolTeacher CreateSchoolTeacher(SchoolTeacher schoolTeacher)
 {
     return(_DbContext.SchoolTeachers.Add(schoolTeacher));
 }
示例#9
0
        public void SchoolRegister(SchoolDTO schoolDto, IEnumerable <DepartmentDTO> departmentDTOs, IEnumerable <CourseDTO> courseDTOs, IEnumerable <TeacherDTO> teacherDTOs)
        {
            using (DatabaseContext context = new DatabaseContext())
            {
                using (DbContextTransaction transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        schoolRegServ = new SchoolRegistrationService(context);
                        var foundSchool = schoolRegServ.FindSchool(schoolDto.SchoolName);
                        if (foundSchool != null)
                        {
                            throw new SchoolRegistrationException();
                        }
                        if (foundSchool == null)
                        {
                            var newSchool = new School
                            {
                                Name         = schoolDto.SchoolName,
                                ContactEmail = schoolDto.SchoolContactEmail,
                                EmailDomain  = schoolDto.SchoolEmailDomain
                            };
                            foundSchool = schoolRegServ.CreateSchool(newSchool);
                            context.SaveChanges();
                        }

                        foreach (DepartmentDTO d in departmentDTOs)
                        {
                            var foundDepartment = schoolRegServ.FindDepartment(d.DepartmentName);
                            if (foundDepartment == null)
                            {
                                var newDepartment = new Department
                                {
                                    Name = d.DepartmentName
                                };
                                foundDepartment = schoolRegServ.CreateDepartment(newDepartment);
                                context.SaveChanges();
                            }

                            var foundSchoolDepartment = schoolRegServ.FindSchoolDepartment(foundSchool.Name, foundDepartment.Name);
                            if (foundSchoolDepartment == null)
                            {
                                var newSchoolDepartment = new SchoolDepartment
                                {
                                    School     = foundSchool,
                                    Department = foundDepartment,
                                };
                                foundSchoolDepartment = schoolRegServ.CreateSchoolDepartment(newSchoolDepartment);
                                context.SaveChanges();
                            }

                            foreach (TeacherDTO t in teacherDTOs)
                            {
                                var foundTeacher = schoolRegServ.FindTeacher(t.FirstName, t.LastName);

                                if (t.DepartmentName.Equals(foundDepartment.Name))
                                {
                                    if (foundTeacher == null)
                                    {
                                        var newTeacher = new Teacher(t.FirstName, t.LastName);

                                        foundTeacher = schoolRegServ.CreateTeacher(newTeacher);
                                        context.SaveChanges();
                                    }

                                    SchoolTeacher foundSchoolTeacher = schoolRegServ.FindSchoolTeacher(foundSchool.Name, foundDepartment.Name, foundTeacher.FirstName, foundTeacher.LastName);
                                    if (foundSchoolTeacher == null)
                                    {
                                        var newSchoolTeacher = new SchoolTeacher
                                        {
                                            Teacher          = foundTeacher,
                                            SchoolDepartment = foundSchoolDepartment
                                        };
                                        foundSchoolTeacher = schoolRegServ.CreateSchoolTeacher(newSchoolTeacher);
                                        context.SaveChanges();
                                    }

                                    foreach (CourseDTO c in courseDTOs)
                                    {
                                        if (c.DepartmentName.Equals(foundDepartment.Name) &&
                                            c.TeacherFirstName.Equals(foundTeacher.FirstName) &&
                                            c.TeacherLastName.Equals(foundTeacher.LastName))
                                        {
                                            var foundCourse = schoolRegServ.FindCourse(c.CourseName);
                                            if (foundCourse == null)
                                            {
                                                var newCourse = new Course
                                                {
                                                    Name             = c.CourseName,
                                                    SchoolDepartment = foundSchoolDepartment
                                                };
                                                foundCourse = schoolRegServ.CreateCourse(newCourse);
                                                context.SaveChanges();
                                            }
                                            SchoolTeacherCourse foundSchoolTeacherCourse = schoolRegServ.FindSchoolTeacherCourse(foundSchool.Name, foundDepartment.Name, foundTeacher.FirstName, foundTeacher.LastName, foundCourse.Name);
                                            if (foundSchoolTeacherCourse == null)
                                            {
                                                var newSchoolTeacherCourse = new SchoolTeacherCourse
                                                {
                                                    SchoolTeacher = foundSchoolTeacher,
                                                    Course        = foundCourse
                                                };
                                                schoolRegServ.CreateSchoolTeacherCourse(newSchoolTeacherCourse);
                                                context.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }


                        transaction.Commit();
                    }
                    catch (SchoolRegistrationException schoolEX)
                    {
                        throw schoolEX;
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                    }
                }
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            string[] name = new string[16];
            string[] family = new string[16];
            int[] years = new int[16];

            for (int i = 0; i < 16; i++)
            {
                Console.Write("Enter fisrt name: ");
                name[i] = Console.ReadLine();
                Console.Write("Enter family name: ");
                family[i] = Console.ReadLine();
                Console.Write("Enter years of working experience: ");
                years[i] = int.Parse(Console.ReadLine());
                Console.WriteLine();

                if (years[i] < 0)
                {
                    break;
                }
            }

            string[] college = new string[] { "Telecommunications College", "Economics College", "Business College" };
            string[] university = new string[] { "Technical University", "Sofia University", "New Bulgarian University" };
            string[] title = new string[] { "Doctor", "Docent" };
            string[] subject = new string[] { "English", "Literature", "History" };
            string exercise1 = "Physics";
            string exercise2 = "Chemistry";
            string exercise3 = "Mathematics";

            Console.WriteLine("--------------------------------------------------------------------------------");

            for (int i = 0; i < 16; i++)
            {
                if (years[i] < 0)
                {
                    break;
                }
                if (i >= 0 && i <= 2)
                {
                    Teacher teacher = new Teacher(name[i], family[i], years[i], subject[i]);
                    teacher.FirstName = name[i];
                    teacher.FamilyName = family[i];
                    teacher.WorkingExperience = years[i];
                    teacher.TeachingSubject = subject[i];
                    Console.WriteLine("{0} {1} has {2} years of working experience and teaches {3}.", teacher.FirstName, teacher.FamilyName, teacher.WorkingExperience, teacher.TeachingSubject);
                    teacher.SayHello();
                    teacher.SayGoodbye();
                    teacher.CheckHomeworks();
                    Console.WriteLine();
                }
                else if (i >= 3 && i <= 5)
                {
                    SchoolTeacher schoolTeacher = new SchoolTeacher();
                    schoolTeacher.FirstName = name[i];
                    schoolTeacher.FamilyName = family[i];
                    schoolTeacher.WorkingExperience = years[i];
                    schoolTeacher.TeachingSubject = subject[i - 3];
                    Console.WriteLine("{0} {1} has {2} years of working experience and teaches {3}.", schoolTeacher.FirstName, schoolTeacher.FamilyName, schoolTeacher.WorkingExperience, schoolTeacher.TeachingSubject);
                    schoolTeacher.SayHello();
                    schoolTeacher.SayGoodbye();
                    schoolTeacher.CheckHomeworks();
                    schoolTeacher.EntertainKids();
                    schoolTeacher.TeachingClasses();
                    Console.WriteLine();
                }
                else if (i >= 6 && i <= 8)
                {
                    CollegeTeacher collegeTeacher = new CollegeTeacher(name[i], family[i], years[i], subject[i - 6], college[i - 6]);
                    collegeTeacher.FirstName = name[i];
                    collegeTeacher.FamilyName = family[i];
                    collegeTeacher.WorkingExperience = years[i];
                    collegeTeacher.TeachingSubject = subject[i - 6];
                    collegeTeacher.TeachingCollege = college[i - 6];
                    Console.WriteLine("{0} {1} has {2} years of working experience and teaches {3} in {4}.", collegeTeacher.FirstName, collegeTeacher.FamilyName, collegeTeacher.WorkingExperience, collegeTeacher.TeachingSubject, collegeTeacher.TeachingCollege);
                    collegeTeacher.SayHello();
                    collegeTeacher.SayGoodbye();
                    collegeTeacher.CheckHomeworks();
                    Console.WriteLine();
                }
                else if (i >= 9 && i <= 11)
                {
                    Lecturer lecturer = new Lecturer(name[i], family[i], years[i], university[i - 9]);
                    lecturer.FirstName = name[i];
                    lecturer.FamilyName = family[i];
                    lecturer.WorkingExperience = years[i];
                    lecturer.TeachingUniversity = university[i - 9];
                    Console.WriteLine("{0} {1} has {2} years of working experience in {3}.", lecturer.FirstName, lecturer.FamilyName, lecturer.WorkingExperience, lecturer.TeachingUniversity);
                    lecturer.SayHello();
                    lecturer.CheckHomeworks();
                    if (i == 9)
                    { lecturer.WageExercise(exercise1); }
                    if (i == 10)
                    { lecturer.WageExercise(exercise1, exercise2); }
                    if (i == 11)
                    { lecturer.WageExercise(exercise1, exercise2, exercise3); }
                    Console.WriteLine("This lecturer can't wage more than {0} lectures per week!", Lecturer.maximumLecturesPerWeek);
                    Console.WriteLine();
                }
                else if (i >= 12 && i <= 13)
                {
                    Professor professor = new Professor(name[i], family[i], years[i], university[i - 12], title[i - 12]);
                    professor.FirstName = name[i];
                    professor.FamilyName = family[i];
                    professor.WorkingExperience = years[i];
                    professor.TeachingUniversity = university[i - 12];
                    professor.Title = title[i - 12];
                    Console.WriteLine("Professor {0} {1} is teaching at {2}.", professor.FirstName, professor.FamilyName, professor.TeachingUniversity);
                    professor.Say(professor.Title, professor.WorkingExperience);
                    professor.CheckHomeworks();
                    Console.WriteLine("This professor can't wage more than {0} lectures per week!", Professor.maximumLecturesPerWeek);
                    professor.WageExams();
                    Console.WriteLine();
                }
                else if (i >= 14 && i <= 15)
                {
                    bool chiefAssistant = true;

                    if (years[i] < 10)
                    { chiefAssistant = false; }

                    Assistant assistant = new Assistant(name[i], family[i], years[i], university[i - 14], chiefAssistant);
                    assistant.FirstName = name[i];
                    assistant.FamilyName = family[i];
                    assistant.WorkingExperience = years[i];
                    assistant.TeachingUniversity = university[i - 14];
                    assistant.ChiefAssistant = chiefAssistant;
                    Console.WriteLine("{0} {1} has {2} years of working experience in {3}.", assistant.FirstName, assistant.FamilyName, assistant.WorkingExperience, assistant.TeachingUniversity);
                    assistant.CheckAssistant(assistant.FirstName, assistant.FamilyName, assistant.ChiefAssistant);
                    assistant.CheckHomeworks();
                    Console.WriteLine("This assistant can't assit in more than {0} lectures per week!", Assistant.maximumLecturesPerWeek);
                    assistant.CheckExams();
                    assistant.WriteScientificArticles();
                    Console.WriteLine();
                }
            }

            Console.WriteLine("TOTAL PERSONS EMPLOYED: " + Person.GetPersonCount());
            Console.WriteLine();
        }