Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public async Task UpdateAsync(UpdateSectionDTO sectionDto)
 {
     var section = _mapper.Map <School.Domain.Section>(sectionDto);
     await _repository.UpdateAsync(section);
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 7
0
 public IActionResult Update([FromBody] UpdateSectionDTO dto)
 {
     _SectionService.Update(dto);
     return(Ok(GetResponse("Updated")));
 }