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"); }); }
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)); }
public Task <ProductDto> UpdateAsync(Guid id, CreateUpdateProductDto input) { return(_service.UpdateAsync(id, input)); }
public Task <ProductDto> CreateAsync(CreateUpdateProductDto input) { return(_service.CreateAsync(input)); }
private async Task HandleProductSubmittedAsync(CreateUpdateProductDto product) { await GetProductsAsync(); }
public async Task <IActionResult> UpdateProduct(Guid id, CreateUpdateProductDto input) { await _productAppService.UpdateProduct(id, input); return(Ok()); }
public async Task <IActionResult> CreateProduct(CreateUpdateProductDto input) { await _productAppService.CreateProduct(input); return(Ok()); }