Exemple #1
0
 public void AddNewPhoto(PhotoDataModel photo)
 {
     using (TheContext ctx = new TheContext())
     {
         ctx.Photos.Add(photo);
         ctx.SaveChanges();
     }
 }
Exemple #2
0
 public void AddNewUser(UserDataModel user)
 {
     using (TheContext ctx = new TheContext())
     {
         ctx.Users.Add(user);
         ctx.SaveChanges();
     }
 }
Exemple #3
0
 public void DeleteAlbum(Guid id)
 {
     using (TheContext ctx = new TheContext())
     {
         var album = ctx.Albums.Include("Photos").FirstOrDefault(a => a.AlbumId == id);
         ctx.Albums.Remove(album);
         ctx.SaveChanges();
     }
 }
Exemple #4
0
 public void SavePhotoInAlbum(Guid id, PhotoDataModel photo)
 {
     using (TheContext ctx = new TheContext())
     {
         var album = ctx.Albums.Include("Photos").FirstOrDefault(a => a.AlbumId == id);
         album.Photos.Add(photo);
         ctx.SaveChanges();
     }
 }
Exemple #5
0
 public void AddNewAlbum(AlbumDataModel album, Guid userId)
 {
     using (TheContext ctx = new TheContext())
     {
         ctx.Albums.Add(album);
         var user = ctx.Users.Include("Albums").FirstOrDefault(x => x.UserId == userId);
         user.Albums.Add(album);
         ctx.SaveChanges();
     }
 }
Exemple #6
0
        public void DeletePhoto(Guid id)
        {
            using (TheContext ctx = new TheContext())
            {
                var photo = ctx.Photos.FirstOrDefault(p => p.PhotoId == id);

                ctx.Photos.Remove(photo);
                ctx.SaveChanges();
            }
        }
Exemple #7
0
        public void DeleteComment(Guid commentId)
        {
            using (TheContext ctx = new TheContext())
            {
                var comment = ctx.Comments.FirstOrDefault(c => c.CommentId == commentId);

                ctx.Comments.Remove(comment);
                ctx.SaveChanges();
            }
        }
Exemple #8
0
        public void AddNewComment(Guid photoId, CommentDataModel comment)
        {
            using (TheContext ctx = new TheContext())
            {
                var photo = ctx.Photos.Single(p => p.PhotoId == photoId);
                photo.Comments.Add(comment);

                ctx.Comments.Add(comment);
                ctx.SaveChanges();
            }
        }