public ActionResult EditProduct(int id) { // Declare productVM Product model; // Get the product Product product = shopBL.EditProduct(id); // Make sure product exists if (product == null) { return(Content("That product does not exist.")); } // init model model = new Product(product); // Make a select list // model.Categories = new SelectList(db.Catagories.ToList(), "Id", "Name"); // Get all gallery images model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")) .Select(fn => Path.GetFileName(fn)); // Return view with model return(View(model)); }