public bool PutTeacherTeachSubjectToSchoolClass(int id, TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass)
        {
            if (id != teacherTeachSubjectToSchoolClass.Id)
            {
                return(false);
            }
            if (db.TeacherTeachSubjectToSchoolClassToStudentRepository.Get(x => x.TeacherTeachSubjectToSchoolClassId == id) != null) // Ne smemo da menjamo "TeacherTeachSubjectToSchoolClass" ako je vec vezan za "TeacherTeachSubjectToSchoolClassToStudent", jer je TeacherTeachSubject vezan za SchoolClass i dalje za Student-e i ocene
            {
                return(false);
            }

            TeacherTeachSubjectToSchoolClass checkTeacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(id);

            if (checkTeacherTeachSubjectToSchoolClass == null)
            {
                return(false);
            }
            checkTeacherTeachSubjectToSchoolClass.TeacherTeachSubject = db.TeacherTeachSubjectRepository.GetByID(teacherTeachSubjectToSchoolClass.TeacherTeachSubjectId);
            checkTeacherTeachSubjectToSchoolClass.SchoolClass         = db.SchoolClassRepository.GetByID(teacherTeachSubjectToSchoolClass.SchoolClassId);

            db.TeacherTeachSubjectToSchoolClassRepository.Update(checkTeacherTeachSubjectToSchoolClass);
            db.Save();

            return(true);
        }
コード例 #2
0
        public IHttpActionResult DeleteTeacherTeachSubjectToSchoolClass(int id)
        {
            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = service.DeleteTeacherTeachSubjectToSchoolClass(id);

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

            return(Ok(teacherTeachSubjectToSchoolClass));
        }
        public TeacherTeachSubjectToSchoolClass DeleteTeacherTeachSubjectToSchoolClass(int id)
        {
            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(id);

            if (teacherTeachSubjectToSchoolClass == null)
            {
                return(null);
            }

            db.TeacherTeachSubjectToSchoolClassRepository.Delete(id);
            db.Save();

            return(teacherTeachSubjectToSchoolClass);
        }
コード例 #4
0
        public IHttpActionResult PutTeacherTeachSubjectToSchoolClass(int id, TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool done = service.PutTeacherTeachSubjectToSchoolClass(id, teacherTeachSubjectToSchoolClass);

            if (done == false)
            {
                return(BadRequest());
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
        public IHttpActionResult PostTeacherTeachSubjectToSchoolClass(TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TeacherTeachSubjectToSchoolClass postedTeacherTeachSubjectToSchoolClass = service.PostTeacherTeachSubjectToSchoolClass(teacherTeachSubjectToSchoolClass);

            if (postedTeacherTeachSubjectToSchoolClass == null)
            {
                return(BadRequest());
            }

            return(Created("", postedTeacherTeachSubjectToSchoolClass));
        }
        public TeacherTeachSubjectToSchoolClass PostTeacherTeachSubjectToSchoolClass(TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass)
        {
            TeacherTeachSubject teacherTeachSubject = db.TeacherTeachSubjectRepository.GetByID(teacherTeachSubjectToSchoolClass.TeacherTeachSubjectId);
            SchoolClass         schoolClass         = db.SchoolClassRepository.GetByID(teacherTeachSubjectToSchoolClass.SchoolClassId);

            if (teacherTeachSubject == null || schoolClass == null)
            {
                return(null);
            }
            TeacherTeachSubjectToSchoolClass newTeacherTeachSubjectToSchoolClass = new TeacherTeachSubjectToSchoolClass();

            newTeacherTeachSubjectToSchoolClass.TeacherTeachSubject = teacherTeachSubject;
            newTeacherTeachSubjectToSchoolClass.SchoolClass         = schoolClass;

            db.TeacherTeachSubjectToSchoolClassRepository.Insert(newTeacherTeachSubjectToSchoolClass);

            //-----------------Za svaki dodati "teacherTeachSubjectToSchoolClass" napunimo "teacherTeachSubjectToSchoolClassToStudent"-------------------------
            //-----------------Svaki Student koji ide u taj SchoolClass dobije taj Subject koji predaje taj Teacher tom SchoolClass-u
            TeacherTeachSubjectToSchoolClassToStudent           teacherTeachSubjectToSchoolClassToStudent;
            TeacherTeachSubjectToSchoolClassToStudentAtSemester teacherTeachSubjectToSchoolClassToStudentAtSemester;

            foreach (var item in schoolClass.Students)
            {
                teacherTeachSubjectToSchoolClassToStudent = new TeacherTeachSubjectToSchoolClassToStudent();
                teacherTeachSubjectToSchoolClassToStudent.TeacherTeachSubjectToSchoolClassId = teacherTeachSubjectToSchoolClass.Id;
                teacherTeachSubjectToSchoolClassToStudent.StudentId = item.Id;
                db.TeacherTeachSubjectToSchoolClassToStudentRepository.Insert(teacherTeachSubjectToSchoolClassToStudent);

                // Dodajemo "teacherTeachSubjectToSchoolClassToStudentAtSemester" za oba semestra
                teacherTeachSubjectToSchoolClassToStudentAtSemester = new TeacherTeachSubjectToSchoolClassToStudentAtSemester();
                teacherTeachSubjectToSchoolClassToStudentAtSemester.TeacherTeachSubjectToSchoolClassToStudent = teacherTeachSubjectToSchoolClassToStudent;
                teacherTeachSubjectToSchoolClassToStudentAtSemester.Semester = db.SemesterRepository.GetByID(SemesterEnum.FIRST);
                db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.Insert(teacherTeachSubjectToSchoolClassToStudentAtSemester);

                teacherTeachSubjectToSchoolClassToStudentAtSemester = new TeacherTeachSubjectToSchoolClassToStudentAtSemester();
                teacherTeachSubjectToSchoolClassToStudentAtSemester.TeacherTeachSubjectToSchoolClassToStudent = teacherTeachSubjectToSchoolClassToStudent;
                teacherTeachSubjectToSchoolClassToStudentAtSemester.Semester = db.SemesterRepository.GetByID(SemesterEnum.SECOND);
                db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.Insert(teacherTeachSubjectToSchoolClassToStudentAtSemester);
            }
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            db.Save();

            return(teacherTeachSubjectToSchoolClass);
        }
コード例 #7
0
        public Lecture PostLecture(Lecture lecture)
        {
            Lesson lesson = db.LessonRepository.GetByID(lecture.LessonId);
            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(lecture.TeacherTeachSubjectToSchoolClassId);

            if (lesson == null || teacherTeachSubjectToSchoolClass == null)
            {
                return(null);
            }
            Lecture newLecture = new Lecture();

            newLecture.Topic  = lecture.Topic;
            newLecture.Date   = DateTime.Now;
            newLecture.Lesson = lesson;
            newLecture.TeacherTeachSubjectToSchoolClass = teacherTeachSubjectToSchoolClass;
            db.LectureRepository.Insert(newLecture);
            db.Save();
            logger.Info("Added new lecture");

            return(newLecture);
        }
コード例 #8
0
        public SchoolClass PutTeacherTeachSubjectToSchoolClass(string id, int teacherTeachSubjectToSchoolClassId)
        {
            SchoolClass schoolClass = db.SchoolClassRepository.GetByID(id);

            if (schoolClass == null)
            {
                return(null);
            }

            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(teacherTeachSubjectToSchoolClassId);

            if (teacherTeachSubjectToSchoolClass == null)
            {
                return(null);
            }

            schoolClass.TeacherTeachSubjectToSchoolClasses.Add(teacherTeachSubjectToSchoolClass);
            db.SchoolClassRepository.Update(schoolClass);
            db.Save();

            return(schoolClass);
        }
コード例 #9
0
        public TeacherTeachSubjectToSchoolClassToStudent PostTeacherTeachSubjectToSchoolClassToStudent(TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent)
        {
            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(teacherTeachSubjectToSchoolClassToStudent.TeacherTeachSubjectToSchoolClassId);
            Student student = db.StudentRepository.GetByID(teacherTeachSubjectToSchoolClassToStudent.StudentId);

            if (teacherTeachSubjectToSchoolClass == null || student == null)
            {
                return(null);
            }
            TeacherTeachSubjectToSchoolClassToStudent newTeacherTeachSubjectToSchoolClassToStudent = new TeacherTeachSubjectToSchoolClassToStudent();

            newTeacherTeachSubjectToSchoolClassToStudent.TeacherTeachSubjectToSchoolClass = teacherTeachSubjectToSchoolClass;
            newTeacherTeachSubjectToSchoolClassToStudent.Student     = student;
            newTeacherTeachSubjectToSchoolClassToStudent.FinaleGrade = null;

            db.TeacherTeachSubjectToSchoolClassToStudentRepository.Insert(newTeacherTeachSubjectToSchoolClassToStudent);
            db.Save();

            return(newTeacherTeachSubjectToSchoolClassToStudent);

            //// ------------------------------------ samo za punjenje baze ----------------------------------------------------
            //foreach (var studentItem in db.StudentRepository.Get())
            //{
            //    TeacherTeachSubjectToSchoolClassToStudent teacherTSubjectToSchoolClassToStudent;
            //    Student student = db.StudentRepository.GetByID(studentItem.Id);
            //    SchoolClass schoolClass = db.SchoolClassRepository.GetByID(student.SchoolClassId);
            //    foreach (var item in schoolClass.TeacherTeachSubjectToSchoolClasses)
            //    {
            //        teacherTSubjectToSchoolClassToStudent = new TeacherTeachSubjectToSchoolClassToStudent();
            //        teacherTSubjectToSchoolClassToStudent.TeacherTeachSubjectToSchoolClass = item;
            //        teacherTSubjectToSchoolClassToStudent.Student = studentItem;
            //        db.TeacherTeachSubjectToSchoolClassToStudentRepository.Insert(teacherTSubjectToSchoolClassToStudent);
            //    }
            //}
            //db.Save();
            //return null;
            //// ----------------------------------------------------------------------------------------------------------------
        }
コード例 #10
0
        public IEnumerable <Lecture> GetLecturesByTeacherTeachSubjectToSchoolClass(int id)
        {
            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(id);

            return(teacherTeachSubjectToSchoolClass.Lectures);
        }
        public TeacherTeachSubjectToSchoolClass GetTeacherTeachSubjectToSchoolClassById(int id)
        {
            TeacherTeachSubjectToSchoolClass teacherTeachSubjectToSchoolClass = db.TeacherTeachSubjectToSchoolClassRepository.GetByID(id);

            return(teacherTeachSubjectToSchoolClass);
        }