public async Task<IActionResult> CreateExam([FromBody] CreatingExamModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } // Todo: need to check all fields before entering a new one. // Todo: Exams with the same date, but with different rooms, are two separate exams var exam = examService.FindByTimeAndRoomAndType(model.Date, model.Room, model.Type, model.CourseId); if (exam.Result == null) { var examId = await examService.CreateNew(model); var students = await courseService.getAllStudentsByCourse(model.CourseId); await examService.AssignStudentsToExam(examId, students); return StatusCode(StatusCodes.Status201Created, examId); } return Conflict(); }