예제 #1
0
        public IHttpActionResult PutAddsStudentsToGradeAndClassNumber(int studentId, int gradeId, int classNumberId)
        {
            Student student = studentService.GetStudent(studentId);

            if (student == null)
            {
                return(NotFound());
            }

            Grade grade = gradeService.GetGrade(gradeId);

            if (grade == null)
            {
                return(NotFound());
            }

            ClassNumber classNumber = classNumberService.GetClassNumber(classNumberId);

            if (classNumber == null)
            {
                return(NotFound());
            }

            student.Grade       = grade;
            student.ClassNumber = classNumber;
            studentService.UpdateStudent(studentId, student.FirstName, student.LastName, student.Username, student.Password,
                                         student.DateOfBirth, student.YearOfEnrollement, student.Gender);
            return(Ok(student));
        }
        public IHttpActionResult DeleteClassNumber(int id)
        {
            ClassNumber classNumber = classNumberService.DeleteClassNumber(id);

            if (classNumber == null)
            {
                return(NotFound());
            }
            return(Ok(classNumber));
        }
        public IHttpActionResult PutClassNumber(int id, ClassNumber classNumber)
        {
            ClassNumber updatedClassNumber = classNumberService.UpdateClassNumber(id, classNumber.ClassName);

            if (updatedClassNumber == null)
            {
                return(NotFound());
            }
            return(Ok(updatedClassNumber));
        }
예제 #4
0
        public void ClassNumberList()
        {
            var list = new List <ClassNumber>();

            for (int i = 0; i < size; i++)
            {
                var tmp = new ClassNumber(0);
                list.Add(tmp);
            }
        }
예제 #5
0
        public void ClassNumberArray()
        {
            var array = new ClassNumber[size];

            for (int i = 0; i < size; i++)
            {
                var tmp = new ClassNumber(0);
                array[i] = tmp;
            }
        }
예제 #6
0
        public IEnumerable <Teacher> GetTeachersByClassNumber(int classNumberId)
        {
            ClassNumber    classNumber = db.ClassNumberRepository.GetByID(classNumberId);
            List <Teacher> teachers    = new List <Teacher>();

            foreach (Teacher teacher in classNumber.Teachers)
            {
                teachers.Add(teacher);
            }
            return(teachers);
        }
예제 #7
0
        public ClassNumber DeleteClassNumber(int id)
        {
            ClassNumber classNumber = db.ClassNumberRepository.GetByID(id);

            if (classNumber != null)
            {
                db.ClassNumberRepository.Delete(id);
                db.Save();
            }
            return(classNumber);
        }
예제 #8
0
        public IEnumerable <Grade> GetGradesByClassNumber(int classNumberId)
        {
            ClassNumber  classNumber = db.ClassNumberRepository.GetByID(classNumberId);
            List <Grade> grades      = new List <Grade>();

            foreach (Grade grade in classNumber.Grades)
            {
                grades.Add(grade);
            }

            return(grades);
        }
예제 #9
0
        public ClassNumber UpdateClassNumber(int id, CLASS_NAME className)
        {
            ClassNumber classNumber = db.ClassNumberRepository.GetByID(id);

            if (classNumber != null)
            {
                classNumber.ClassName = className;

                db.ClassNumberRepository.Update(classNumber);
                db.Save();
            }

            return(classNumber);
        }
예제 #10
0
        public void ClassNumberArrayPool()
        {
            var arrayPool = ArrayPool <ClassNumber> .Shared;
            var array     = arrayPool.Rent(size);

            try
            {
                for (int i = 0; i < size; i++)
                {
                    var tmp = new ClassNumber(0);
                    array[i] = tmp;
                }
            }
            finally
            {
                arrayPool.Return(array);
            }
        }
예제 #11
0
        public IHttpActionResult PutAddsGradesToClassNumbers(int gradeId, int classNumberId)
        {
            Grade grade = gradeService.GetGrade(gradeId);

            if (grade == null)
            {
                return(NotFound());
            }

            ClassNumber classNumber = classNumberService.GetClassNumber(classNumberId);

            if (classNumber == null)
            {
                return(NotFound());
            }

            gradeService.UpdateGrade(gradeId, grade.Name);
            return(Ok(grade));
        }
예제 #12
0
        public IEnumerable <Student> GetStudentsByGradeAndClassNumber(int gradeId, int classNumberId)
        {
            Grade          grade       = db.GradeRepository.GetByID(gradeId);
            ClassNumber    classNumber = db.ClassNumberRepository.GetByID(classNumberId);
            List <Student> students    = new List <Student>();

            foreach (Student student in grade.Students)
            {
                students.Add(student);
            }

            foreach (Student student in classNumber.Students)
            {
                students.Add(student);
            }



            return(students);
        }
예제 #13
0
        public IHttpActionResult PutAddsTeachersToClasses(int teacherId, int classNumberId)
        {
            Teacher teacher = teacherService.GetTeacher(teacherId);

            if (teacher == null)
            {
                return(NotFound());
            }

            ClassNumber classNumber = classNumberService.GetClassNumber(classNumberId);

            if (classNumber == null)
            {
                return(NotFound());
            }

            teacherService.UpdateTeacher(teacherId, teacher.FirstName, teacher.LastName, teacher.Username, teacher.Password, teacher.Qualifications,
                                         teacher.YearsOfExperience, teacher.Email);

            return(Ok(teacher));
        }
        public IHttpActionResult PostClassNumber(ClassNumber classNumber)
        {
            ClassNumber createdClassNumber = classNumberService.CreateClassNumber(classNumber);

            return(Created("", createdClassNumber));
        }
예제 #15
0
 public ClassNumber CreateClassNumber(ClassNumber classNumber)
 {
     db.ClassNumberRepository.Insert(classNumber);
     db.Save();
     return(classNumber);
 }