예제 #1
0
        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" );
            }
        }
예제 #2
0
		private void attach_Galleries(Gallery entity)
		{
			this.SendPropertyChanging();
			entity.Users = this;
		}
예제 #3
0
		private void detach_Galleries(Gallery entity)
		{
			this.SendPropertyChanging();
			entity.Users = null;
		}
예제 #4
0
 partial void DeleteGallery(Gallery instance);
예제 #5
0
 partial void UpdateGallery(Gallery instance);
예제 #6
0
 partial void InsertGallery(Gallery instance);
예제 #7
0
 public void Delete( Gallery picture )
 {
     db.Galleries.DeleteOnSubmit( picture );
 }
예제 #8
0
 public void Add( Gallery picture )
 {
     db.Galleries.InsertOnSubmit( picture );
 }