示例#1
0
        public async Task <IActionResult> AddProduct(ViewModels.PM.AddProductViewModel addProductViewModel)
        {
            if (ModelState.IsValid)
            {
                ImageErrorModel imageErrorModel = new ImageErrorModel();
                string          ImagePath       = UploadImage(addProductViewModel.DefaultImage, ref imageErrorModel);
                if (imageErrorModel.isSuccess)
                {
                    Product product = new Product()
                    {
                        //MetaKey=addProductViewModel.MetaKey,
                        MetaTitle       = addProductViewModel.MetaTitle,
                        MetaDescription = addProductViewModel.MetaDescription,
                        Model           = addProductViewModel.Model,
                        //MetaKey=adProductViewModel.MetaTitle,
                        DefaultImage   = ImagePath,
                        Price          = addProductViewModel.DefauftPrice,
                        isOnlineOnly   = addProductViewModel.isOnlineOnly,
                        IsAllowComment = addProductViewModel.IsAllowComment,
                        StockMin       = addProductViewModel.StockMin,
                        //LadingPage = addProductViewModel.LadingPage,
                    };
                    product.BrandID    = addProductViewModel.Brand;
                    product.CategoryID = addProductViewModel.Category;
                    //product.MainGroup = await MainGroupBLL.Find(addProductViewModel.MainGroup);
                    product.SubGroupID = addProductViewModel.SubGroup;
                    await ProductBLL.Add(product);

                    return(RedirectToAction("Index"));
                }
            }
            return(View());
        }