Beispiel #1
0
        public async Task <ActionResult> UpdateUniversity([FromRoute] Guid id, [FromBody] UpdateUniversityDto updateUniversityDto, CancellationToken ct)
        {
            if (!await _universityService.ExistsAsync(id, ct))
            {
                return(NotFound());
            }

            var universityToReturn = await _universityService.UpdateUniversityAsync(id, updateUniversityDto, ct);

            if (universityToReturn == null)
            {
                return(BadRequest());
            }

            return(Ok(universityToReturn));
        }
Beispiel #2
0
        public async Task <UniversityDto> PartialUpdateUniversityAsync(Guid id, UpdateUniversityDto updateUniversityDto, CancellationToken ct)
        {
            var universityEntity = await _uow.Universities.GetAsync(id, ct);

            _mapper.Map(updateUniversityDto, universityEntity);

            await _uow.Universities.UpdateAsync(universityEntity, id, ct, universityEntity.RowVersion);

            await _uow.SaveChangesAsync(ct);

            universityEntity = await _uow.Universities.GetAsync(id, ct);

            var universityDto = _mapper.Map <UniversityDto>(universityEntity);

            return(universityDto);
        }