コード例 #1
0
        public async Task <ConfigGenericItemDto> UpdateConfigGenericItemDto(UpdateConfigGenericItemRequestDto request, string userName)
        {
            _logger.LogDebug($"Updating config generic item with group Id {request.GroupId} and Id {request.Id}");

            await _updateValidator.ValidateAndThrowAsync(request);

            var entity = await _dbContext.ConfigGenericItems.SingleOrDefaultAsync(x => x.GroupId == request.GroupId && x.Id == request.Id);

            if (entity != null)
            {
                _mapper.Map(request, entity);
                entity.LastUpdatedDate     = DateTime.Now;
                entity.LastUpdatedUserName = userName;

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

                return(_mapper.Map <ConfigGenericItemDto>(entity));
            }

            _logger.LogError($"Update config generic item, entity not found : Cannot found entity with groupId {request.GroupId} and Id {request.Id}");
            return(null);
        }
コード例 #2
0
 public async Task <ConfigGenericItemDto> UpdateConfigGenericItemAsync([FromBody] UpdateConfigGenericItemRequestDto request)
 {
     return(await _configGenericItemService.UpdateConfigGenericItemDto(request, Account?.FullName));
 }