Exemplo n.º 1
0
 public AlbumEntityModel ShowAlbum(Guid id)
 {
     using (var context = new MVCLabbRepositoryDbContext())
     {
         return(context.AlbumEntityModels.Include("Comment").FirstOrDefault(x => x.AlbumId == id));
     }
 }
Exemplo n.º 2
0
 public PhotoEntityModel GetPhoto(Guid id)
 {
     using (var context = new MVCLabbRepositoryDbContext())
     {
         return(context.PhotoEntityModels.Include("Comment").FirstOrDefault(p => p.PhotoId == id));
     }
 }
Exemplo n.º 3
0
 public List <AlbumEntityModel> GetAllAlbums()
 {
     using (var context = new MVCLabbRepositoryDbContext())
     {
         var albums = context.AlbumEntityModels.Include("Comment").Include("Photo").ToList();
         return(albums);
     }
 }
Exemplo n.º 4
0
 public List <PhotoEntityModel> GetAllPhoto()
 {
     using (var context = new MVCLabbRepositoryDbContext())
     {
         var photos = context.PhotoEntityModels.Include("Comment").ToList();
         //context.PhotoEntityModels.AddOrUpdate(photos);
         return(photos);
     }
 }
Exemplo n.º 5
0
 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();
     }
 }
Exemplo n.º 6
0
 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();
     }
 }
Exemplo n.º 7
0
 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();
     }
 }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
 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();
     }
 }
Exemplo n.º 10
0
 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();
     }
 }
Exemplo n.º 11
0
 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);
     }
 }
Exemplo n.º 12
0
 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();
     }
 }