Example #1
0
        public IActionResult Update(int studentId, int courseId, [FromBody] MarksModel model)
        {
            var mark = marksRepository.GetById(studentId, courseId);

            if (mark == null)
            {
                return(NotFound("Mark does not exist for this student."));
            }

            if (model.MarkValue < 6 || model.MarkValue > 10)
            {
                return(BadRequest("Invalid mark. Allowed values: 6 - 10"));
            }

            mark.MarkValue = model.MarkValue;

            marksRepository.Save();

            return(new NoContentResult());
        }