public virtual async Task <ProductInventoryDto> GetAsync(Guid productId, Guid productSkuId)
        {
            var productInventory = await _repository.FindAsync(x => x.ProductSkuId == productSkuId);

            if (productInventory == null)
            {
                productInventory = new ProductInventory(GuidGenerator.Create(), productId, productSkuId, 0, 0);

                await _repository.InsertAsync(productInventory, true);
            }

            return(ObjectMapper.Map <ProductInventory, ProductInventoryDto>(productInventory));
        }
Exemplo n.º 2
0
        protected virtual async Task <ProductInventory> GetOrCreateProductInventoryAsync(Guid productId,
                                                                                         Guid productSkuId)
        {
            var productInventory =
                await _productInventoryRepository.FindAsync(x =>
                                                            x.ProductId == productId && x.ProductSkuId == productSkuId);

            if (productInventory is null)
            {
                productInventory = new ProductInventory(_guidGenerator.Create(), _currentTenant.Id, productId,
                                                        productSkuId, 0, 0);

                await _productInventoryRepository.InsertAsync(productInventory, true);
            }

            return(productInventory);
        }