public virtual ActionResult Add(IEnumerable <HttpPostedFileBase> files, GalleryTable galleriesTable, string category) { if (files != null) { if (category != null) { foreach (var file in files) { var path = Path.Combine(Server.MapPath("~/Content/Images/Gallery/"), galleriesTable.Category.Replace(' ', '-') + file.FileName.Replace(' ', '-').Replace('+', '-').Replace("'", "-").Replace("*", "-").Replace("!", "-").Replace("?", "-")); _modelGallery.Add(galleriesTable.Category.Replace(' ', '-') + file.FileName.Replace(' ', '-').Replace('+', '-').Replace("'", "-").Replace("*", "-").Replace("!", "-").Replace("?", "-"), category); file.SaveAs(path); } return(RedirectToAction("index", "allgallery")); } else { return(RedirectToAction("index", "newgallery")); } } else { return(RedirectToAction("index", "newgallery")); } }
public ModelGallery() { _galleryContext = new FashionSiteContext(); _galleryTable = new GalleryTable(); }