public FinaleSemesterGrade PostFinaleSemesterGrade(FinaleSemesterGradeDTO finaleSemesterGradeDto)
        {
            TeacherTeachSubjectToSchoolClassToStudentAtSemester teacherTeachSubjectToSchoolClassToStudentAtSemester = db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.GetByID(finaleSemesterGradeDto.TeacherTeachSubjectToSchoolClassToStudentAtSemesterId);

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

            // Ako vec postoji FinaleSemesterGrade za dati TeacherTeachSubjectToSchoolClassToStudentAtSemester vracamo null
            FinaleSemesterGrade check = db.FinaleSemesterGradeRepository.Get(x => x.TeacherTeachSubjectToSchoolClassToStudentAtSemester.Id == teacherTeachSubjectToSchoolClassToStudentAtSemester.Id).FirstOrDefault();

            if (check != null)
            {
                return(null);
            }
            FinaleSemesterGrade finaleSemesterGrade = new FinaleSemesterGrade();

            finaleSemesterGrade.Mark = finaleSemesterGradeDto.Mark;
            finaleSemesterGrade.Date = DateTime.Now;
            finaleSemesterGrade.TeacherTeachSubjectToSchoolClassToStudentAtSemester = teacherTeachSubjectToSchoolClassToStudentAtSemester;
            db.FinaleSemesterGradeRepository.Insert(finaleSemesterGrade);
            db.Save();

            logger.Info("Added new finale semester grade");
            Utilities.Utils.FinaleSemesterGradeMailSender(finaleSemesterGrade);

            return(finaleSemesterGrade);
        }
        public IHttpActionResult PutFinaleSemesterGrade(int id, FinaleSemesterGradeDTO finaleSemesterGradeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool done = service.PutFinaleSemesterGrade(id, finaleSemesterGradeDto);

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostFinaleSemesterGrade(FinaleSemesterGradeDTO finaleSemesterGradeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            FinaleSemesterGrade postedFinaleSemesterGrade = service.PostFinaleSemesterGrade(finaleSemesterGradeDto);

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

            return(Created("", postedFinaleSemesterGrade));
        }
        public bool PutFinaleSemesterGrade(int id, FinaleSemesterGradeDTO finaleSemesterGradeDto)
        {
            if (id != finaleSemesterGradeDto.GradeId)
            {
                return(false);
            }

            FinaleSemesterGrade checkFinaleSemesterGrade = db.FinaleSemesterGradeRepository.GetByID(id);

            if (checkFinaleSemesterGrade == null)
            {
                return(false);
            }
            checkFinaleSemesterGrade.Mark = finaleSemesterGradeDto.Mark;
            checkFinaleSemesterGrade.Date = DateTime.Now;
            checkFinaleSemesterGrade.TeacherTeachSubjectToSchoolClassToStudentAtSemester = db.TeacherTeachSubjectToSchoolClassToStudentAtSemesterRepository.GetByID(finaleSemesterGradeDto.TeacherTeachSubjectToSchoolClassToStudentAtSemesterId);

            db.FinaleSemesterGradeRepository.Update(checkFinaleSemesterGrade);
            db.Save();
            logger.Info("Updated finale semester grade (id:{0})", checkFinaleSemesterGrade.GradeId);

            return(true);
        }