public async Task <IActionResult> CreateSection([FromBody] SetSectionResource sectionResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(await _classAppService.CreateSection(sectionResource))); }
public async Task <GetSectionResource> CreateSection(SetSectionResource sectionResource) { var resultGroupe = new Groupe(); var resultSousGroupe = new SousGroupe(); //CreateSection var resultSection = _mapper.Map <SetSectionResource, Section>(sectionResource); _sectionrepository.Add(resultSection); await _unitOfWork.CompleteAsync(); //CreateSectionGroupe resultGroupe = new Groupe { RefGroupe = "G1", SectionId = resultSection.Id }; _groupeRepository.Add(resultGroupe); await _unitOfWork.CompleteAsync(); //CreateGroupeSousGroupe resultSousGroupe = new SousGroupe { RefSousGroupe = "SG1", GroupeId = resultGroupe.Id }; _sGroupeRepository.Add(resultSousGroupe); await _unitOfWork.CompleteAsync(); //JoinThem resultGroupe.SousGroupes.Add(resultSousGroupe); resultSection.Groupes.Add(resultGroupe); return(_mapper.Map <Section, GetSectionResource>(resultSection)); }