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 PutFinaleGrade(int id, FinaleGradeDTO finaleGradeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool done = service.PutFinaleGrade(id, finaleGradeDto);

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostFinaleGrade(FinaleGradeDTO finaleGradeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            FinaleGrade postedFinaleGrade = service.PostFinaleGrade(finaleGradeDto);

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

            return(Created("", postedFinaleGrade));
        }
        public bool PutFinaleGrade(int id, FinaleGradeDTO finaleGradeDto)
        {
            if (id != finaleGradeDto.GradeId)
            {
                return(false);
            }

            FinaleGrade checkFinaleGrade = db.FinaleGradeRepository.GetByID(id);

            if (checkFinaleGrade == null)
            {
                return(false);
            }
            checkFinaleGrade.Mark = finaleGradeDto.Mark;
            checkFinaleGrade.Date = DateTime.Now;
            checkFinaleGrade.TeacherTeachSubjectToSchoolClassToStudent = db.TeacherTeachSubjectToSchoolClassToStudentRepository.GetByID(finaleGradeDto.TeacherTeachSubjectToSchoolClassToStudentId);

            db.FinaleGradeRepository.Update(checkFinaleGrade);
            db.Save();

            logger.Info("Updated finale grade (id:{0})", checkFinaleGrade.GradeId);
            return(true);
        }