コード例 #1
0
        public IActionResult AddManufacturer(int ProductID)
        {
            var product = _Iproduct.GetProductByID(ProductID);
            var model   = new AddManufacturerVM
            {
                productID = ProductID
            };

            _database.Add(new AdminActivity
            {
                ActivityID     = 8,
                AdminID        = Int32.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)),
                DateOfActivity = DateTime.Now
            });
            _database.SaveChanges();

            return(View(model));
        }
コード例 #2
0
        public IActionResult SaveManufacturer(AddManufacturerVM 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));
            }

            Manufacturer manufacturer = new Manufacturer
            {
                ManufacturerName = model.manufacturerName,
                LogoUrl          = uniquefileName
            };

            _Iproduct.AddManufacturer(manufacturer);
            return(Redirect($"/Product/AddProduct?={model.productID}"));
        }