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); }
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); }
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; }
public async Task <ActionResult <int> > Put(int id, UpdatePlaceDto updatePlaceDto) { await _placeCommandService.UpdatePlace(id, updatePlaceDto); return(NoContent()); }