public IActionResult CreateCatalogue(int schoolId, [FromBody] CatalogueDTO catalogueDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Catalogue catalogue = new Catalogue() { Name = catalogueDTO.Name, Mentors = catalogueDTO.Mentors, Students = catalogueDTO.Students, Courses = catalogueDTO.Courses, Grades = catalogueDTO.Grades }; _schoolRepository.AddCatalogue(catalogue, schoolId); return(CreatedAtRoute("GetCatalogue", new { schoolId, catalogueId = catalogue.Id }, catalogue)); }
public IActionResult CreateCatalogue(int schoolId, [FromBody] CatalogueDTO catalogueDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int maxCatalogueId = _schoolRepository.GetSchool(schoolId).CataloguesList.Max(c => c.Id); Catalogue catalogue = new Catalogue() { Id = ++maxCatalogueId, ClassName = catalogueDTO.ClassName, ClassMentors = catalogueDTO.ClassMentors, ClassStudents = catalogueDTO.ClassStudents, ClassCourses = catalogueDTO.ClassCourses, ClassGrades = catalogueDTO.ClassGrades }; _schoolRepository.AddCatalogue(catalogue, schoolId); return(CreatedAtRoute("GetCatalogue", new { schoolId, catalogueId = catalogue.Id }, catalogue)); }