예제 #1
0
        public async Task <IActionResult> Ekle(ProductViewModel p)
        {
            if (p.File.Length > 0)
            {
                var x = Path.Combine(_environment.WebRootPath, @"Images");
                //var x = Path.Combine(Directory.GetCurrentDirectory(), @"Images");
                var filePath = Path.Combine(x, p.File.FileName);
                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    await p.File.CopyToAsync(stream);

                    p.MyProduct.ProductImg = p.File.FileName;
                }
            }
            _dal.AddProduct(p.MyProduct);
            return(RedirectToAction("Index"));
        }
예제 #2
0
 public void Add(Product product)
 {
     ProductValidation(product);
     _productDal.AddProduct(product);
 }