public IActionResult CreateCatalogueMentor(int schoolId, int catalogueId, [FromBody] CataloguePersonDTO cataloguePersonDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Mentor mentor = _schoolRepository.GetMentor(cataloguePersonDTO.Id, schoolId); Catalogue catalogue = _schoolRepository.GetCatalogue(catalogueId, schoolId); foreach (Mentor ment in catalogue.Mentors) { if (ment.Id == mentor.Id) { return(Conflict(mentor.Name)); } } _schoolRepository.AddCatalogueMentor(mentor, schoolId, catalogueId); return(CreatedAtRoute("GetCatalogueMentor", new { schoolId, catalogueId, mentorId = mentor.Id }, mentor)); }