public async Task <IActionResult> CreateProfesseur([FromBody] long ecoleId, ProfesseurCreateDto professeurCreateDto) { if (professeurCreateDto.name == null) { return(BadRequest()); } Ecole ecole = await _ecoleRepository.GetById(ecoleId); if (ecole == null) { return(NotFound()); } Professeur professeur = Professeur.From(professeurCreateDto); professeur.Ecole = ecole; await _professeurRepository.CreateEntity(professeur); var res = await _ecoleRepository.SaveAsync(); if (!res) { return(BadRequest()); } return(Created("professeur/me", professeur)); }
public async Task <IActionResult> CreateEleve([FromBody] long ecoleId, EleveCreateDto eleveCreateDto) { if (eleveCreateDto.name == null) { return(BadRequest()); } Ecole ecole = await _ecoleRepository.GetById(ecoleId); if (ecole == null) { return(NotFound()); } Eleve eleve = eleve.From(eleveCreateDto); eleve.Ecole = ecole; await _eleveRepository.CreateEntity(eleve); var res = await _ecoleRepository.SaveAsync(); if (!res) { return(BadRequest()); } return(Created("professeur/me", eleve)); }
public async Task <IActionResult> CreateEcole([FromBody] EcoleCreateDto ecoleCreateDto) { if (ecoleCreateDto.name == null) { return(BadRequest()); } Ecole ecole = Ecole.From(ecoleCreateDto); await _ecoleRepository.CreateEntity(ecole); var res = await _ecoleRepository.SaveAsync(); if (!res) { return(BadRequest()); } return(Created("ecole/me", ecole)); }