Beispiel #1
0
        public IActionResult SaveSubCategory(AddSubCategoryVM model)
        {
            string uniquefileName = null;

            if (model.Image != null)
            {
                string uploadsFolder = Path.Combine(hosting.WebRootPath, "images");
                uniquefileName = Guid.NewGuid().ToString() + "_" + model.Image.FileName;
                string filePath = Path.Combine(uploadsFolder, uniquefileName);
                model.Image.CopyTo(new FileStream(filePath, FileMode.Create));
            }

            SubCategory subcategory = new SubCategory
            {
                SubCategoryName = model.subcategoryName,
                CategoryID      = model.categoryID,
                ImageUrl        = uniquefileName
            };

            _Iproduct.AddSubCategory(subcategory);
            return(Redirect("/Administration/Index"));
        }