Beispiel #1
0
        private bool ImportProductData()
        {
            var productFile = _productFileRepository.ProductFile();

            foreach (var product in productFile)
            {
                var details = product.Split(',', 2);

                if (Double.TryParse(details[1], out var price))
                {
                    _logger.LogInformation($"Loading Details for Product {details[0]}");
                    _productUoW.ProductRepository.CreateProduct(details[0], price);
                }
            }

            return(_productUoW.Save());
        }
Beispiel #2
0
        public bool CreateNewProduct(string sku, double price, int discountAmount, double discountPrice)
        {
            if (sku == string.Empty)
            {
                return(false);
            }

            var product = _productUoW.ProductRepository.CreateProduct(sku, price);

            if (discountAmount > 0)
            {
                product.Discount = _productUoW.DiscountFileRepository.CreateDiscount(discountAmount, discountPrice * -1);
            }

            return(_productUoW.Save());
        }