Example #1
0
        public virtual void InsertProduct(NaseejProduct product)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            //insert
            _productRepository.Insert(product);
        }
Example #2
0
        public virtual void UpdateProduct(NaseejProduct product)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            //update
            _productRepository.Update(product);
        }
Example #3
0
        public virtual void DeleteProduct(NaseejProduct product)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            product.Deleted = true;
            //delete product
            UpdateProduct(product);
        }
Example #4
0
        public ProductModel PrepareProductModel(ProductModel model, NaseejProduct product)
        {
            if (product != null)
            {
                //fill in model values from the entity
                model = model ?? product.ToModel <ProductModel>();  // Auomapper and dto

                var Product = _productService.GetProductById(product.Id);
            }

            if (product == null)
            {
                if (model.ItemCount > model.Quantity)
                {
                    throw new Exception();
                }
            }

            return(model);
        }