public ActionResult AddToPrivate(Albums album, int id) { HomeModel homeModel = new HomeModel(); List <Comments> pictureComments = new List <Comments>(); var currentUserId = UserId(User.Identity.Name); using (ProjektEntities context = new ProjektEntities()) { PicturesAlbums picturesAlbums = new PicturesAlbums { pictures_id = id, album_id = album.id }; context.PicturesAlbums.Add(picturesAlbums); context.SaveChanges(); var comments = from c in context.Comments join u in context.Users on c.id_user equals u.id into ps where c.id_picture == id select new { Comment = c, Users = ps }; foreach (var comment in comments) { pictureComments.Add(comment.Comment); } homeModel.pictureComments = pictureComments; } return(PartialView("Comment", homeModel)); }
private void BackButton_Click(object sender, EventArgs e) { Thread T = new Thread(delegate() { SplashWindow.CreateCoverSplash(PicturesContainer.Top, PicturesContainer.Left, PicturesContainer.Height, PicturesContainer.Width); }); T.Start(); while (!SplashWindow.bSmallCreated) { ; } bShow = false; PicturesAlbums.BringToFront(); PicturesAlbums.Focus(); PicturesAlbums.AlbumItems[PicturesAlbums.ItemsDT.Rows.IndexOf(PicturesAlbums.ItemsDT.Select("AlbumID = " + iAlbumID)[0])].LikesCount = InfiniumPictures.RefreshLikes(iAlbumID); BackButton.Visible = false; bC = true; }
public ActionResult Upload(HttpPostedFileBase file, Pictures Picture) { var currentUserId = UserId(User.Identity.Name); if (file != null && Picture.title != null) { string pic = System.IO.Path.GetFileName(file.FileName); string path = System.IO.Path.Combine( Server.MapPath("~/UserPictureImages/"), pic); string pathDB = pic; // file is uploaded file.SaveAs(path); using (ProjektEntities context = new ProjektEntities()) { Pictures Picture2 = new Pictures { AlbumId = Picture.AlbumId, title = Picture.title, description = Picture.description, img = pic, id_user = currentUserId, }; context.Pictures.Add(Picture2); PicturesAlbums pical = new PicturesAlbums { album_id = Picture2.AlbumId, pictures_id = Picture2.id }; context.PicturesAlbums.Add(pical); context.SaveChanges(); } return(RedirectToAction("Index", "Home")); } else { Pictures PictureModel = new Pictures(); using (ProjektEntities context = new ProjektEntities()) { PictureModel.AlbumCollection = context.Albums.ToList <Albums>(); } return(View("Upload", PictureModel)); } }