示例#1
0
        public async Task Should_Create_A_Product()
        {
            // Arrange
            _eShopProductsOptions.Groups.Configure("Default Group Name", x =>
            {
                x.DisplayName = "Default Group Name";
                x.Description = "Default Description";
            });

            var requestDto = new CreateUpdateProductDto
            {
                ProductGroupName  = "Default Group Name",
                ProductDetailId   = ProductsTestData.ProductDetails1Id,
                StoreId           = ProductsTestData.Store1Id,
                UniqueName        = "Unique Pencil",
                DisplayName       = "Pencil",
                InventoryStrategy = InventoryStrategy.NoNeed,
                DisplayOrder      = 0,
                IsPublished       = true,
                ProductAttributes = new List <CreateUpdateProductAttributeDto>
                {
                    new CreateUpdateProductAttributeDto
                    {
                        DisplayName             = "Default Attribute 1",
                        Description             = "Default Description 1",
                        DisplayOrder            = 1,
                        ProductAttributeOptions = new List <CreateUpdateProductAttributeOptionDto>
                        {
                            new CreateUpdateProductAttributeOptionDto
                            {
                                DisplayName = "Option 1"
                            }
                        }
                    }
                }
            };

            // Act
            var response = await _productAppService.CreateAsync(requestDto);

            // Assert
            response.ShouldNotBeNull();
            response.IsPublished.ShouldBe(true);
            response.DisplayName.ShouldBe("Pencil");
            response.UniqueName.ShouldBe("Unique Pencil");

            UsingDbContext(db =>
            {
                var product = db.Products.FirstOrDefault(x => x.Id == response.Id);
                product.ShouldNotBeNull();
                product.DisplayName.ShouldBe("Pencil");
            });
        }
示例#2
0
        public async Task Should_Check_ProductDetailId()
        {
            var wrongProductDetailId = Guid.NewGuid();

            var requestDto = new CreateUpdateProductDto
            {
                ProductGroupName  = "Default Group Name",
                StoreId           = ProductsTestData.Store1Id,
                UniqueName        = "Unique Pencil",
                DisplayName       = "Pencil",
                ProductDetailId   = wrongProductDetailId,
                InventoryStrategy = InventoryStrategy.NoNeed,
                DisplayOrder      = 0,
                IsPublished       = true,
                ProductAttributes = new List <CreateUpdateProductAttributeDto>
                {
                    new CreateUpdateProductAttributeDto
                    {
                        DisplayName             = "Default Attribute 1",
                        Description             = "Default Description 1",
                        DisplayOrder            = 1,
                        ProductAttributeOptions = new List <CreateUpdateProductAttributeOptionDto>
                        {
                            new CreateUpdateProductAttributeOptionDto
                            {
                                DisplayName = "Option 1"
                            }
                        }
                    }
                }
            };

            // Act
            (await Should.ThrowAsync <EntityNotFoundException>(async() =>
            {
                await _productAppService.CreateAsync(requestDto);
            })).EntityType.ShouldBe(typeof(ProductDetail));
        }
示例#3
0
 public Task <ProductDto> UpdateAsync(Guid id, CreateUpdateProductDto input)
 {
     return(_service.UpdateAsync(id, input));
 }
示例#4
0
 public Task <ProductDto> CreateAsync(CreateUpdateProductDto input)
 {
     return(_service.CreateAsync(input));
 }
示例#5
0
 private async Task HandleProductSubmittedAsync(CreateUpdateProductDto product)
 {
     await GetProductsAsync();
 }
示例#6
0
        public async Task <IActionResult> UpdateProduct(Guid id, CreateUpdateProductDto input)
        {
            await _productAppService.UpdateProduct(id, input);

            return(Ok());
        }
示例#7
0
        public async Task <IActionResult> CreateProduct(CreateUpdateProductDto input)
        {
            await _productAppService.CreateProduct(input);

            return(Ok());
        }