Ejemplo n.º 1
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}"));
        }