public FinaleGrade PostFinaleGrade(FinaleGradeDTO finaleGradeDto) { TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent = db.TeacherTeachSubjectToSchoolClassToStudentRepository.GetByID(finaleGradeDto.TeacherTeachSubjectToSchoolClassToStudentId); if (teacherTeachSubjectToSchoolClassToStudent == null) { return(null); } // Ako vec postoji FinaleGrade za dati TeacherTeachSubjectToSchoolClassToStudent vracamo null FinaleGrade check = db.FinaleGradeRepository.Get(x => x.TeacherTeachSubjectToSchoolClassToStudent.Id == teacherTeachSubjectToSchoolClassToStudent.Id).FirstOrDefault(); if (check != null) { return(null); } FinaleGrade finaleGrade = new FinaleGrade(); finaleGrade.Mark = finaleGradeDto.Mark; finaleGrade.Date = DateTime.Now; finaleGrade.TeacherTeachSubjectToSchoolClassToStudent = teacherTeachSubjectToSchoolClassToStudent; db.FinaleGradeRepository.Insert(finaleGrade); db.Save(); logger.Info("Added new finale grade"); Utilities.Utils.FinaleGradeMailSender(finaleGrade); return(finaleGrade); }
public IHttpActionResult DeleteTeacherTeachSubjectToSchoolClassToStudent(int id) { TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent = service.DeleteTeacherTeachSubjectToSchoolClassToStudent(id); if (teacherTeachSubjectToSchoolClassToStudent == null) { return(NotFound()); } return(Ok(teacherTeachSubjectToSchoolClassToStudent)); }
public TeacherTeachSubjectToSchoolClassToStudent DeleteTeacherTeachSubjectToSchoolClassToStudent(int id) { TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent = db.TeacherTeachSubjectToSchoolClassToStudentRepository.GetByID(id); if (teacherTeachSubjectToSchoolClassToStudent == null) { return(null); } db.TeacherTeachSubjectToSchoolClassToStudentRepository.Delete(id); db.Save(); return(teacherTeachSubjectToSchoolClassToStudent); }
//public Student PostStudent(StudentDTO studentDto) public async Task <IdentityResult> PostStudent(StudentDTO studentDto) { //pri prvom unosu Teacher-a dodeljujemo mu default-ni username i password i setujemo Parent na null vrednost. Student student = new Student(); // Cim se kreira Student (bilo koja klasa koja nasledjuje User-a) sa "new" automatski mu se dodeljuje vrednost Guid! student.UserName = Utils.CreateUserNameForStudent(studentDto, db); //student.Password = String.Concat(studentDto.FirstName, "123"); student.FirstName = studentDto.FirstName; student.LastName = studentDto.LastName; student.Email = studentDto.Email; student.SchoolClass = db.SchoolClassRepository.GetByID(studentDto.SchoolClassId); student.Parent = null; //db.StudentRepository.Insert(student); //db.AuthRepository.RegisterStudent(student, /*parentDto.Password*/String.Concat(studentDto.FirstName, "123")); //db.Save(); logger.Info("Added new student"); var result = await db.AuthRepository.RegisterStudent(student, String.Concat(studentDto.FirstName, "123")); if (result.Succeeded) // dodajemo Student-a u "teacherTeachSubjectToSchoolClassToStudent" { TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent; TeacherTeachSubjectToSchoolClassToStudentAtSemester teacherTeachSubjectToSchoolClassToStudentAtSemester; SchoolClass schoolClass = db.SchoolClassRepository.GetByID(student.SchoolClassId); foreach (var item in schoolClass.TeacherTeachSubjectToSchoolClasses) // Student koji je dodat u taj SchoolClass dobija sve Subject-e koje predaju odredjeni Teacher-i tom SchoolClass-u { teacherTeachSubjectToSchoolClassToStudent = new TeacherTeachSubjectToSchoolClassToStudent(); teacherTeachSubjectToSchoolClassToStudent.TeacherTeachSubjectToSchoolClassId = item.Id; teacherTeachSubjectToSchoolClassToStudent.StudentId = student.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(result); //return student; }
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); }
public bool PutTeacherTeachSubjectToSchoolClassToStudent(int id, TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent) { if (id != teacherTeachSubjectToSchoolClassToStudent.Id) { return(false); } TeacherTeachSubjectToSchoolClassToStudent checkTeacherTeachSubjectToSchoolClassToStudent = db.TeacherTeachSubjectToSchoolClassToStudentRepository.GetByID(id); if (checkTeacherTeachSubjectToSchoolClassToStudent == null) { return(false); } db.TeacherTeachSubjectToSchoolClassToStudentRepository.Update(checkTeacherTeachSubjectToSchoolClassToStudent); db.Save(); return(true); }
public TeacherTeachSubjectToSchoolClassToStudentAtSemester PostTeacherTeachSubjectToSchoolClassToStudentAtSemester(TeacherTeachSubjectToSchoolClassToStudentAtSemester teacherTeachSubjectToSchoolClassToStudentAtSemester) { TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent = db.TeacherTeachSubjectToSchoolClassToStudentRepository.GetByID(teacherTeachSubjectToSchoolClassToStudentAtSemester.TeacherTeachSubjectToSchoolClassToStudentId); if (teacherTeachSubjectToSchoolClassToStudent == null) { return(null); } TeacherTeachSubjectToSchoolClassToStudentAtSemester newTeacherTeachSubjectToSchoolClassToStudentAtSemester = new TeacherTeachSubjectToSchoolClassToStudentAtSemester(); newTeacherTeachSubjectToSchoolClassToStudentAtSemester.TeacherTeachSubjectToSchoolClassToStudent = teacherTeachSubjectToSchoolClassToStudent; newTeacherTeachSubjectToSchoolClassToStudentAtSemester.FinaleSemesterGrade = null; //newTeacherTeachSubjectToSchoolClassToStudentAtSemester.SemesterName = teacherTeachSubjectToSchoolClassToStudentAtSemester.SemesterName; newTeacherTeachSubjectToSchoolClassToStudentAtSemester.Semester = db.SemesterRepository.GetByID(teacherTeachSubjectToSchoolClassToStudentAtSemester.SemesterName); db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.Insert(newTeacherTeachSubjectToSchoolClassToStudentAtSemester); db.Save(); return(newTeacherTeachSubjectToSchoolClassToStudentAtSemester); //// ------------------------------------ samo za punjenje baze ---------------------------------------------------- //TeacherTeachSubjectToSchoolClassToStudentAtSemester teacherTeachSubjectToSchoolClassToStudentAtSemesterFill; //foreach (var item in db.TeacherTeachSubjectToSchoolClassToStudentRepository.Get()) //{ // // Dodajemo "teacherTeachSubjectToSchoolClassToStudentAtSemester" za oba semestra // teacherTeachSubjectToSchoolClassToStudentAtSemesterFill = new TeacherTeachSubjectToSchoolClassToStudentAtSemester(); // teacherTeachSubjectToSchoolClassToStudentAtSemesterFill.TeacherTeachSubjectToSchoolClassToStudent = item; // teacherTeachSubjectToSchoolClassToStudentAtSemesterFill.Semester = db.SemesterRepository.GetByID(SemesterEnum.FIRST); // db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.Insert(teacherTeachSubjectToSchoolClassToStudentAtSemesterFill); // teacherTeachSubjectToSchoolClassToStudentAtSemesterFill = new TeacherTeachSubjectToSchoolClassToStudentAtSemester(); // teacherTeachSubjectToSchoolClassToStudentAtSemesterFill.TeacherTeachSubjectToSchoolClassToStudent = item; // teacherTeachSubjectToSchoolClassToStudentAtSemesterFill.Semester = db.SemesterRepository.GetByID(SemesterEnum.SECOND); // db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.Insert(teacherTeachSubjectToSchoolClassToStudentAtSemesterFill); //} //db.Save(); //return null; //// ---------------------------------------------------------------------------------------------------------------- }
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; //// ---------------------------------------------------------------------------------------------------------------- }
public TeacherTeachSubjectToSchoolClassToStudent GetTeacherTeachSubjectToSchoolClassToStudentById(int id) { TeacherTeachSubjectToSchoolClassToStudent teacherTeachSubjectToSchoolClassToStudent = db.TeacherTeachSubjectToSchoolClassToStudentRepository.GetByID(id); return(teacherTeachSubjectToSchoolClassToStudent); }