public async Task <ActionResult <School> > AddSchool(School school) { try { var schools = await _schoolRepository.AddSchool(school); if (schools == null) { return(NotFound()); } return(Ok(new { schools.Name, schools.Address, schools.ContactName, schools.ContactEmail, schools.ContactPhoneNo })); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error in Retrieving Data from Database")); } }
public int AddSchool(SchoolModel schoolModel) { try { return(schoolRepository.AddSchool(schoolModel)); } catch (Exception ex) { throw ex; } }
public IActionResult CreateSchool([FromBody] SchoolDTO schoolDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } School school = new School() { Name = schoolDTO.Name, Principal = schoolDTO.Principal, Photo = schoolDTO.Photo, Mentors = schoolDTO.Mentors, Students = schoolDTO.Students, Courses = schoolDTO.Courses, Catalogues = schoolDTO.Catalogues, Subjects = schoolDTO.Subjects }; _schoolRepository.AddSchool(school); return(CreatedAtRoute("GetSchool", new { schoolId = school.Id }, school)); }
public IActionResult CreateSchool([FromBody] SchoolDTO schoolDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int maxSchoolId = _schoolRepository.GetAllSchools().Max(s => s.Id); School school = new School() { Id = ++maxSchoolId, Name = schoolDTO.Name, Principal = schoolDTO.Principal, MentorsList = schoolDTO.MentorsList, StudentsList = schoolDTO.StudentsList, CoursesList = schoolDTO.CoursesList, CataloguesList = schoolDTO.CataloguesList }; _schoolRepository.AddSchool(school); return(CreatedAtRoute("GetSchool", new { schoolId = school.Id }, school)); }
public async Task <int> AddSchool(SchoolDTO school) { return(await _schoolRepository.AddSchool(school)); }