public void Create(CreateSectionDTO dto) { var Section = new SectionDbEntity(); Section.Description = dto.Description; Section.Name = dto.Name; _DB.Sections.Add(Section); _DB.SaveChanges(); }
public async Task <ActionResult> Post([FromBody] CreateSectionDTO sectionDTO) { if (!ModelState.IsValid) { return(BadRequest()); } await _sectionService.CreateAsync(sectionDTO); return(Ok()); }
[HttpPost] //POST /api/tak public async Task <IActionResult> AddTak([FromBody] CreateSectionDTO viewmodel) { var tak = new Tak { Naam = viewmodel.Naam, Volgorde = viewmodel.Volgorde, TabIsAllowed = viewmodel.TabIsAllowed }; await _takRepository.AddAsync(tak); await _takRepository.SaveChangesAsync(); var model = _mapper.Map <BasicSectionDTO>(tak); return(CreatedAtRoute("GetTakById", new { id = model.Id }, model)); }
public async Task <IActionResult> UpdateTak([FromRoute] int id, [FromBody] CreateSectionDTO viewmodel) { var tak = await _takRepository.FindByIdAsync(id); if (tak == null) { return(NotFound($"Tak met id {id} werd niet gevonden")); } tak.Naam = viewmodel.Naam; tak.Volgorde = viewmodel.Volgorde; tak.TabIsAllowed = viewmodel.TabIsAllowed; // _takRepository.Update(tak); await _takRepository.SaveChangesAsync(); var model = _mapper.Map <BasicSectionDTO>(tak); return(Ok(model)); }
public async Task CreateAsync(CreateSectionDTO SectionDto) { var section = _mapper.Map <School.Domain.Section>(SectionDto); await this._repository.CreateAsync(section); }
public IActionResult Create([FromBody] CreateSectionDTO dto) { _SectionService.Create(dto); return(Ok(GetResponse("Added"))); }