public override int Delete(Users user)
        {
            NoteRepository    nr = new NoteRepository();
            LikedRepository   lr = new LikedRepository();
            CommentRepository cr = new CommentRepository();

            foreach (var note in user.Notes.ToList())
            {
                foreach (Liked like in note.Likes.ToList())
                {
                    lr.Delete(like);
                }

                foreach (Comment comment in note.Comments.ToList())
                {
                    cr.Delete(comment);
                }

                nr.Delete(note);
            }
            List <Liked>   Likedd  = lr.List(x => x.LikedUser.Id == user.Id);
            List <Comment> Comment = cr.List(x => x.Owner.Id == user.Id);

            foreach (var item in Likedd)
            {
                lr.Delete(item);
            }
            foreach (var item in Comment)
            {
                cr.Delete(item);
            }
            return(base.Delete(user));
        }
Ejemplo n.º 2
0
        public override int Delete(Note note)
        {
            NoteRepository    nr = new NoteRepository();
            LikedRepository   lr = new LikedRepository();
            CommentRepository cr = new CommentRepository();
            UserRepository    ur = new UserRepository();

            List <Liked>   Likedd  = lr.List(x => x.Note.Id == note.Id);
            List <Comment> Comment = cr.List(x => x.Note.Id == note.Id);

            foreach (var item in Likedd)
            {
                lr.Delete(item);
            }
            foreach (var item in Comment)
            {
                cr.Delete(item);
            }

            return(base.Delete(note));
        }