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