Как добавить новую запись с вложенностью?

Мне нужно сделать относительно простой функционал для добавления товара в список товара. Есть сущности DTO:

public class WishlistItemDto
    {
        public int Id { get; set; }

        public string CustomerId { get; set; }

        public ProductDetailsDtoWithPrimaryImage ProductDetails { get; set; }

        public int Quantity { get; set; }
    }

public class WishListItemCreationDto
    {
        public string CustomerId { get; set; }

        public int ProductDetailId { get; set; }

        public int Quantity { get; set; }
    }

Возникла проблема с добавлением товара в список. Прошелся Дебагом, и в сервисe переменная entityDetails=null. Вот как выглядит код:

//Controller
        [HttpPost]
        public async Task<IActionResult> Add(WishListItemCreationDto wishListItemDto)
        {
            var itemAdd = _mapper.Map<WishlistItemDto>(wishListItemDto);
            //itemAdd.ProductDetails.Id = wishListItemDto.ProductDetailId;
            var itemCreated = await _wishListItemService.AddAsync(itemAdd);

            return CreatedAtAction(nameof(GetId), new { id = itemCreated.Id }, wishListItemDto);
        }

        //Service
        public async Task<WishlistItemDto> AddAsync(WishlistItemDto item)
        {
            var entity = _mapper.Map<WishlistItem>(item);
            var entityDetails = await _productDetailsRepository.GetById(item.ProductDetails.Id);
            entity.ProductDetails = entityDetails;
            await _wishListItemRepository.AddAsync(entity);

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

Ответы (0 шт):