public IActionResult CreatProductImage(IFormFile imagename) { string imgname = ""; int id = int.Parse(TempData["ProductImage"].ToString()); if (imagename != null) { if (ImageSecurity.ImageValidator(imagename)) { imgname = imagename.SaveImage("", "wwwroot/Layout/img/Gallery"); string olldpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Layout/img/Gallery", imgname); string newpath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Layout/img/Prodoctsubimg", imgname); olldpath.Image_resize(newpath, 150, 150); ProductImg productImg = new ProductImg { ProdoctImgName = imgname, ProductId = id }; GalleryService.AddProductImage(productImg); } else { return(RedirectToAction(nameof(GalleryList), new { id = id })); } } return(RedirectToAction(nameof(GalleryList), new { id = id })); }