public ProductDto CreateProduct(UpsertProductArgs args) { _createProductArgsValidator.ValidateAndThrow <UpsertProductArgs>(args); var product = _mapper.Map <Product>(args); var persistedProduct = _productRepository.CreateProduct(product); return(_mapper.Map <ProductDto>(persistedProduct)); }
public void UpdateProduct_UpdatesNonIdentityFieldsInPersistedProduct(string productName, double retailPrice, string sellByType) { var args = new UpsertProductArgs(productName, (decimal)retailPrice, sellByType); var persistedProductDto = _productConfigurationService.UpdateProduct(args); persistedProductDto.Name.Should().Be(args.Name); persistedProductDto.RetailPrice.Should().Be(args.RetailPrice); persistedProductDto.SellByType.Should().Be(args.SellByType); }
public ProductDto UpdateProduct(UpsertProductArgs args) { _updateProductArgsValidator.ValidateAndThrow <UpsertProductArgs>(args); var product = _productRepository.FindProduct(args.Name); _mapper.Map <UpsertProductArgs, Product>(args, product); var persistedProduct = _productRepository.UpdateProduct(product); return(_mapper.Map <ProductDto>(persistedProduct)); }
public void TestName() { var args = new UpsertProductArgs { Name = "something", RetailPrice = 1, SellByType = "Unit" }; var productDto = _productController.CreateProduct(args).Value; productDto.Name.Should().Be(args.Name); productDto.RetailPrice.Should().Be(args.RetailPrice); productDto.SellByType.Should().Be(args.SellByType); }
public ActionResult <ProductDto> UpdateProduct(string productName, [FromBody] UpsertProductArgs args) { args.Name = productName; return(_productConfigurationService.UpdateProduct(args)); }
public ActionResult <ProductDto> CreateProduct([FromBody] UpsertProductArgs args) { return(_productConfigurationService.CreateProduct(args)); }