public IHttpActionResult PutSemesterGrade(int id, SemesterGradeDTO semesterGradeDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool done = service.PutSemesterGrade(id, semesterGradeDto); if (done == false) { return(BadRequest()); } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostSemesterGrade(SemesterGradeDTO semesterGradeDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SemesterGrade postedSemesterGrade = service.PostSemesterGrade(semesterGradeDto); if (postedSemesterGrade == null) { return(BadRequest()); } return(Created("", postedSemesterGrade)); }
public SemesterGrade PostSemesterGrade(SemesterGradeDTO semesterGradeDto) { TeacherTeachSubjectToSchoolClassToStudentAtSemester teacherTeachSubjectToSchoolClassToStudentAtSemester = db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.GetByID(semesterGradeDto.TeacherTeachSubjectToSchoolClassToStudentAtSemesterId); if (teacherTeachSubjectToSchoolClassToStudentAtSemester == null) { return(null); } SemesterGrade semesterGrade = new SemesterGrade(); semesterGrade.Mark = semesterGradeDto.Mark; semesterGrade.Date = DateTime.Now; semesterGrade.TeacherTeachSubjectToSchoolClassToStudentAtSemester = teacherTeachSubjectToSchoolClassToStudentAtSemester; db.SemesterGradeRepository.Insert(semesterGrade); db.Save(); logger.Info("Added new semester grade"); Utilities.Utils.GradeMailSender(semesterGrade); return(semesterGrade); }
public bool PutSemesterGrade(int id, SemesterGradeDTO semesterGradeDto) { if (id != semesterGradeDto.GradeId) { return(false); } SemesterGrade checkSemesterGrade = db.SemesterGradeRepository.GetByID(id); if (checkSemesterGrade == null) { return(false); } checkSemesterGrade.Mark = semesterGradeDto.Mark; checkSemesterGrade.Date = DateTime.Now; checkSemesterGrade.TeacherTeachSubjectToSchoolClassToStudentAtSemester = db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.GetByID(semesterGradeDto.TeacherTeachSubjectToSchoolClassToStudentAtSemesterId); db.SemesterGradeRepository.Update(checkSemesterGrade); db.Save(); logger.Info("Updated semester grade (id:{0})", checkSemesterGrade.GradeId); return(true); }