public void Update(UpdateSectionDTO dto) { var Section = _DB.Sections.SingleOrDefault(x => x.Id == dto.Id && !x.IsDeleted); if (Section != null) { Section.Name = dto.Name; Section.UpdatedAt = DateTime.Now; Section.Description = dto.Description; _DB.Sections.Update(Section); _DB.SaveChanges(); } }
public async Task <ActionResult> Put([FromBody] UpdateSectionDTO sectionDTO) { if (!ModelState.IsValid) { return(BadRequest()); } var section = await _sectionService.GetAsync(sectionDTO.Id); if (section != null) { await _sectionService.UpdateAsync(sectionDTO); return(NoContent()); } return(NotFound()); }
public async Task <BasicLeaderDTO> ChangeSectionOfLeader(int leaderId, UpdateSectionDTO dto) { var leader = await _leidingRepository.FindByIdAsync(leaderId); if (leader == null) { throw new EntityNotFoundException($"Leiding met id {leaderId} werd niet gevonden."); } var newSection = await _takRepository.FindByIdAsync(dto.NewSectionId); if (newSection == null) { throw new EntityNotFoundException($"Nieuwe tak met id {dto.NewSectionId} werd niet gevonden."); } leader.Tak = newSection; await _leidingRepository.SaveChangesAsync(); var model = _mapper.Map <BasicLeaderDTO>(leader); return(model); }
public async Task UpdateAsync(UpdateSectionDTO sectionDto) { var section = _mapper.Map <School.Domain.Section>(sectionDto); await _repository.UpdateAsync(section); }
public Task <ApiResponseAsync <bool> > UpdateSectionName(UpdateSectionDTO dto) { var rev = this._notes.UpdateSectionName(dto.NotesId, dto.Id, dto.Body); return(ApiRes.OKAsync(rev)); }
public async Task <IActionResult> ChangeTak([FromRoute] int leidingId, [FromBody] UpdateSectionDTO viewModel) { var updatedLeader = await _leaderService.ChangeSectionOfLeader(leidingId, viewModel); return(Ok(updatedLeader)); }
public IActionResult Update([FromBody] UpdateSectionDTO dto) { _SectionService.Update(dto); return(Ok(GetResponse("Updated"))); }