コード例 #1
0
        public async Task <PeopleDetailedDto> UpdatePeopleAsync(UpdatePeopleRequestDto request, string userName)
        {
            _logger.LogError($"Update existing people. Request : {JsonConvert.SerializeObject(request)}");

            await _updateValidator.ValidateAndThrowAsync(request);

            var entity = await _dbContext.Peoples.SingleOrDefaultAsync(x => x.Id == request.Id);

            if (entity == null)
            {
                _logger.LogError($"Cannot find people entity with Id {request.Id}");
                return(null);
            }

            _mapper.Map(request, entity);
            entity.LastUpdatedDate     = DateTime.Now;
            entity.LastUpdatedUserName = userName;

            _dbContext.Update(entity);
            await _dbContext.SaveChangesAsync();

            return(_mapper.Map <PeopleDetailedDto>(entity));
        }
コード例 #2
0
 public async Task <PeopleDetailedDto> UpdatePeopleAsync([FromBody] UpdatePeopleRequestDto request)
 {
     return(await _peopleService.UpdatePeopleAsync(request, Account?.FullName));
 }