Пример #1
0
        public void AddNewProduct(Product product, ProductCategory category)
        {
            try
            {
                //var existCategory = new ProductCategory()
                //{
                //    Id = category.Id
                //}; // _categoryRepository.GetAll().Where(i => i.Id == category.Id);

                //product.ProductCategories.Add(existCategory);

                product.ProductCategories.Add(category);

                _productRepository.Add(product, category);
                //_uow.Save();

            }
            catch (Exception ex)
            {
                throw new Exception("Failed adding the product", ex);
            }
        }
Пример #2
0
        public void UpdateProductImg(Product product)
        {
            var currentUser = UserManager.FindById(User.Identity.GetUserId());
            var prfileId = currentUser.UserProfile.Id;
            var supplierId = _merchantService.FindSupplierBy(prfileId).Id;

            //product.ProductImgLargeUrl = "";
            //product.ProductImgSmallUrl = "";
            product.SupplierId = supplierId;

            //var updatedProduct = _productServices.FindProductById(product.Id);

            _productServices.UpdateProductImg(product);
        }
Пример #3
0
        public void AddProduct(Product product, Core.Entities.ProductCategory category)
        {
            var newProduct = new Product();

            var currentUser = UserManager.FindById(User.Identity.GetUserId());
            var prfileId = currentUser.UserProfile.Id;
            var supplierId = _merchantService.FindSupplierBy(prfileId).Id;

            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                newProduct.ProductName = product.ProductName;
                newProduct.ProductDescLong = product.ProductDescLong;
                newProduct.ProductDescShort = product.ProductDescShort;
                newProduct.ProductImgLargeUrl = "/Content/Assets/Images/product_default_lg.png";
                newProduct.ProductImgSmallUrl = "/Content/Assets/Images/product_default_sm.png";
                newProduct.UnitName = product.UnitName;
                newProduct.Notes = product.Notes;
                newProduct.UnitsInStock = 0;//Not implemented
                newProduct.UnitPrice = product.UnitPrice;
                newProduct.SupplierId = supplierId;
                newProduct.ProductAvailable = product.ProductAvailable;
                newProduct.CreateDate = DateTime.Now;
                newProduct.UpdateDate = DateTime.Now;

                _productServices.AddNewProduct(newProduct, category);
            }
        }
Пример #4
0
        public void UpdateProductImg(Product product)
        {
            try
            {
                //ProductCategory category = _categoryRepository.GetAll().FirstOrDefault(i => i.Id == id);
                product.UpdateDate = DateTime.Now;
                //category.DepartmentId = 1;

                _productRepository.Update(product);
                _uow.Save();
            }
            catch (Exception ex)
            {
                throw new Exception("Failed updating the product", ex);
            }
        }