public ActionResult Create(FormCollection collection) { try { var picture = new Gallery(); // TODO: Add insert logic here var info = new StringBuilder(); foreach (string file in Request.Files) { HttpPostedFileBase postedFile = Request.Files[file]; if (postedFile.ContentLength == 0) continue; var newFileName = Guid.NewGuid() + "-" + postedFile.FileName; string newFilePath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory + @"Content\Gallery\", Path.GetFileName( newFileName ) ); postedFile.SaveAs( newFilePath ); picture.name = Request.Form["name"]; picture.filename = newFileName; picture.upload_by = galleryRepository.GetAuthorId( User.Identity.Name ); picture.upload_date = DateTime.UtcNow; galleryRepository.Add( picture ); galleryRepository.Save(); } return RedirectToAction("Index"); } catch { return View( "Error" ); } }
private void attach_Galleries(Gallery entity) { this.SendPropertyChanging(); entity.Users = this; }
private void detach_Galleries(Gallery entity) { this.SendPropertyChanging(); entity.Users = null; }
partial void DeleteGallery(Gallery instance);
partial void UpdateGallery(Gallery instance);
partial void InsertGallery(Gallery instance);
public void Delete( Gallery picture ) { db.Galleries.DeleteOnSubmit( picture ); }
public void Add( Gallery picture ) { db.Galleries.InsertOnSubmit( picture ); }