public EvenementImage UploadAndCreate(HttpPostedFileBase file) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images", file.FileName); File.UploadHttpFile(file, path); var evtImage = new EvenementImage() { Title = file.FileName, Path = path }; evtImageRepository.Create(evtImage); return(evtImage); }
public void Create(Evenement evt, HttpFileCollectionBase files) { var evtImageRepository = this.eventRepository.CreateRepository <EvenementImage>(); this.eventRepository.Create(evt); for (var i = 0; i < files.Count; i++) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content", "images", files[i].FileName); if (File.UploadHttpFile(files[i], path)) { var evtImage = new EvenementImage() { Title = files[i].FileName, Path = Path.Combine("/", "Content", "images", files[i].FileName), Evenement = this.eventRepository.Find(evt.Id) }; evtImageRepository.Create(evtImage); } } }