Example #1
0
        public void UpsertProductMarkdown_UpsertsProductMarkdown(string productName, decimal amountOffRetail, DateTime?startTime, DateTime?endTime)
        {
            var args = new UpsertProductMarkdownArgs(productName, amountOffRetail, startTime, endTime);

            var persistedProduct = _productMarkdownConfigurationService.UpsertProductMarkdown(args);

            persistedProduct.Name.Should().Be(args.ProductName);
            persistedProduct.Markdown.AmountOffRetail.Should().Be(args.AmountOffRetail);
            persistedProduct.Markdown.StartTime.Should().Be(args.StartTime.Value);
            persistedProduct.Markdown.EndTime.Should().Be(args.EndTime.Value);
        }
Example #2
0
        public ProductDto UpsertProductMarkdown(UpsertProductMarkdownArgs args)
        {
            _upsertProductMarkdownArgsValidator.ValidateAndThrow <UpsertProductMarkdownArgs>(args);

            var product = _productRepository.FindProduct(args.ProductName);

            if (product.Markdown == null)
            {
                product.Markdown = _mapper.Map <Markdown>(args);
            }
            else
            {
                _mapper.Map <UpsertProductMarkdownArgs, Markdown>(args, product.Markdown);
            }

            var persistedProduct = _productRepository.UpdateProduct(product);

            return(_mapper.Map <ProductDto>(persistedProduct));
        }
Example #3
0
 public ActionResult <ProductDto> CreateMarkdown(string productName, [FromBody] UpsertProductMarkdownArgs args)
 {
     args.ProductName = productName;
     return(_productMarkdownConfigurationService.UpsertProductMarkdown(args));
 }