public IActionResult ProductsAddOrUpdate(Product product, IFormFile[] files, IFormFile model, IFormFile mainfile) { product.ImageForTarget = SaveFile(mainfile, "products") ?? product.ImageForTarget; product.Model = SaveFile(model, "products") ?? product.ImageForTarget; if (files.Any()) { product.texturesObj = new List <string>(); files.ToList().ForEach(f => product.texturesObj.Add(SaveFile(f, "products"))); product.texturesObj = product.texturesObj.Where(i => i != null).ToList(); } Products.AddOrUpdate(product); ViewData["Categories"] = Categories.Get(); return(RedirectToAction(nameof(ProductsList))); }