示例#1
0
        public int Add(ProductViewModel product, string userId)
        {
            var domainModelProduct = new Product()
            {
                Name = product.Name, ShortDescription = product.ShortDescription, LongDescription = product.LongDescription, Price = product.Price
            };

            domainModelProduct.Image     = MemoryPostedFile.GetFileBytes(product.Image.InputStream);
            domainModelProduct.CreatedBy = userId;
            var productId = _unitOfWork.ProductsRepository.AddProduct(domainModelProduct);

            return(productId);
        }
示例#2
0
        public bool Update(ProductViewModel product, string userId)
        {
            var domainModelProduct = new Product()
            {
                Id = product.Id, Name = product.Name, ShortDescription = product.ShortDescription, LongDescription = product.LongDescription, Price = product.Price
            };

            domainModelProduct.Image = product.Image == null?_unitOfWork.ProductsRepository.GetProduct(product.Id).Image : MemoryPostedFile.GetFileBytes(product.Image.InputStream);

            domainModelProduct.UpdatedBy = userId;
            return(_unitOfWork.ProductsRepository.UpdateProduct(domainModelProduct));
        }