public static UpdatePlaceDto Update(this PlaceDetailDto placeDetail, string updateName = null, string updateDescription = null, IList <WriteEntityExtendedPropertyDto> extendedProperties = null)
        {
            var update = new UpdatePlaceDto
            {
                Id          = placeDetail.Id,
                Description = updateDescription ?? placeDetail.Description,
                Name        = updateName ?? placeDetail.Name,
                PlaceExtendedPropertyList = extendedProperties ?? new List <WriteEntityExtendedPropertyDto>(placeDetail.PlaceExtendedPropertyList)
            };

            return(update);
        }
示例#2
0
        public async Task UpdatePlace(int id, UpdatePlaceDto updatePlaceDto)
        {
            _logger.LogInformation("{class}.{method} with id = [{id}] Invoked", nameof(PlaceCommandService), nameof(UpdatePlace), id);

            var userGuid = _httpContextUserService.GetUserGuid();
            var place    = await _placeRepository.GetById(id, userGuid);

            if (place is null || place.Deleted)
            {
                throw new EntityNotFoundException <Place>($"Id = [{id}], UserGuid = [{userGuid}]");
            }

            _placeMappingService.Map(updatePlaceDto, place);
            await _unitOfWork.Commit();

            _logger.LogInformation("{entityName} with id = [{id}] has been updated in local database", nameof(Place), place.Id);

            var @event = _placeMappingService.MapToPlaceUpdatedEvent(place);

            _eventBusPublisher.Publish(@event);

            _logger.LogInformation("{entityName} with id = [{id}] has been successfully updated", nameof(Place), place.Id);
        }
示例#3
0
 public void Map(UpdatePlaceDto updatePlaceDto, Place place)
 {
     place.Name          = string.IsNullOrEmpty(updatePlaceDto.Name) ? place.Name : updatePlaceDto.Name;
     place.Description   = string.IsNullOrEmpty(updatePlaceDto.Description) ? place.Description : updatePlaceDto.Description;
     place.ParentPlaceId = updatePlaceDto.ParentPlaceId;
 }
示例#4
0
        public async Task <ActionResult <int> > Put(int id, UpdatePlaceDto updatePlaceDto)
        {
            await _placeCommandService.UpdatePlace(id, updatePlaceDto);

            return(NoContent());
        }