예제 #1
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);
            }

        }
예제 #2
0
        public void UpdateCategory(Core.Entities.ProductCategory category)
        {
            //ProductCategory categoryForUpdate = _categoryService.FindCategoryById(category.Id);

            //categoryForUpdate.ProductCategoryName = category.ProductCategoryName;
            //categoryForUpdate.ProductCategoryDesc = category.ProductCategoryDesc;
            //categoryForUpdate.UpdateDate = DateTime.Now;



            _categoryService.UpdateCategory(category);
        }