public void AddNewAlbumComment(Guid albumid, CommentsEntityModel newalbumCommet) { using (var context = new MVCLabbRepositoryDbContext()) { var albumentity = context.AlbumEntityModels.FirstOrDefault(a => a.AlbumId == albumid); albumentity.Comment.Add(newalbumCommet); context.AlbumEntityModels.AddOrUpdate(albumentity); context.SaveChanges(); } }
public void DeletePhoto(PhotoEntityModel photo) { using (var context = new MVCLabbRepositoryDbContext()) { var photoToDelete = context.PhotoEntityModels.Include("Comment").FirstOrDefault(p => p.PhotoId == photo.PhotoId); context.PhotoEntityModels.Remove(photoToDelete); context.PhotoEntityModels.AddOrUpdate(photoToDelete); context.SaveChanges(); } }
public void AddNewPhotoComment(Guid photoid, CommentsEntityModel newphotoComment) { using (var context = new MVCLabbRepositoryDbContext()) { var photoentity = context.PhotoEntityModels.FirstOrDefault(p => p.PhotoId == photoid); photoentity.Comment.Add(newphotoComment); context.PhotoEntityModels.AddOrUpdate(photoentity); context.SaveChanges(); } }
public PhotoEntityModel AddCommentToPhoto(Guid id, string photoComment) { using (var context = new MVCLabbRepositoryDbContext()) { var phototocomment = context.PhotoEntityModels.Include("Comment").FirstOrDefault(x => x.PhotoId == id); phototocomment.Comment.Add(new CommentsEntityModel { Id = Guid.NewGuid(), CommentPhoto = photoComment }); context.PhotoEntityModels.AddOrUpdate(phototocomment); context.SaveChanges(); return(phototocomment); } }
public void AddPhoto(PhotoEntityModel newphoto) { using (var context = new MVCLabbRepositoryDbContext()) { PhotoEntityModel photo = new PhotoEntityModel(); photo.PhotoId = newphoto.PhotoId; photo.PhotoName = newphoto.PhotoName; photo.Comment = newphoto.Comment; context.PhotoEntityModels.Add(photo); context.PhotoEntityModels.AddOrUpdate(photo); context.SaveChanges(); } }
public void AddPhotoToAlbum(IEnumerable <Guid> photos, Guid albumID) { using (var context = new MVCLabbRepositoryDbContext()) { var albumToAddIn = context.AlbumEntityModels.FirstOrDefault(x => x.AlbumId == albumID); foreach (var item in photos) { albumToAddIn.Photo.Add(context.PhotoEntityModels.Include("Comment").FirstOrDefault(x => x.PhotoId == item)); } context.AlbumEntityModels.AddOrUpdate(albumToAddIn); context.SaveChanges(); } }
public AlbumEntityModel AddCommentToAlbum(Guid id, string albumComment) { using (var context = new MVCLabbRepositoryDbContext()) { var albumtocomment = context.AlbumEntityModels.Include("Comment").FirstOrDefault(x => x.AlbumId == id); albumtocomment.Comment.Add(new CommentsEntityModel { Id = Guid.NewGuid(), CommentAlbum = albumComment }); context.AlbumEntityModels.AddOrUpdate(albumtocomment); context.SaveChanges(); return(albumtocomment); } }
public void AddNewAlbum(AlbumEntityModel newalbum) { using (var context = new MVCLabbRepositoryDbContext()) { AlbumEntityModel album = new AlbumEntityModel(); album.AlbumId = newalbum.AlbumId; album.AlbumName = newalbum.AlbumName; album.Comment = newalbum.Comment; //album.Photo = newalbum.Photo; context.AlbumEntityModels.Add(album); context.AlbumEntityModels.AddOrUpdate(album); context.SaveChanges(); } }