public void Delete(Guid id) { using (var ctx = new Labb1Context()) { var images = ctx.image.Single(x => x.Id == id); ctx.image.Remove(images); ctx.SaveChanges(); } }
public void AddCommentToAlbum(Guid id, string albumComment) { using (var ctx = new Labb1Context()) { var addCommentToAlbum = new Comments() { CommentsAlbums = albumComment }; ctx.comment.Add(addCommentToAlbum); ctx.SaveChanges(); } }
public void AddImageToAlbum(Guid imageID, Guid albumID) { using (var ctx = new Labb1Context()) { var AddImagesToAlbum = new AlbumImages() { AlbumID = albumID, Id = imageID }; ctx.albumImage.Add(AddImagesToAlbum); ctx.SaveChanges(); } }
public void Add(ModelGallery image) { using (var ctx = new Labb1Context()) { var newImage = new ModelGallery { Id = Guid.NewGuid(), Name = image.Name, dateAdded = DateTime.Now }; ctx.image.Add(newImage); ctx.SaveChanges(); } }
public ActionResult CreateAlbum(AlbumModel album) { //album.AlbumID = Guid.NewGuid(); //album.Date = DateTime.Now; //Albums.Add(album); //return Redirect("ListAlbums"); using (var ctx = new Labb1Context()) { album.AlbumID = Guid.NewGuid(); ctx.album.Add(album); ctx.SaveChanges(); } return(View()); }
public void AddComment(ModelGallery image, string ImageComment) { using (var ctx = new Labb1Context()) { var CommentImage = ctx.image.First(a => a.Id == image.Id); if (CommentImage != null) { var MYCOMMENT = new Comments() { CommentsImages = ImageComment, ModelGallery_Id = CommentImage }; ctx.comment.Add(MYCOMMENT); ctx.SaveChanges(); } } }