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