Skip to content

Commit

Permalink
Kategori silme işleminde karşılaşılan ilişkili veri sebebiyle silinem…
Browse files Browse the repository at this point in the history
…emesinin çözülmesi.
  • Loading branch information
muratbaseren committed Apr 3, 2018
1 parent 2a94465 commit da778e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions MyEvernote.BusinessLayer/CategoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ namespace MyEvernote.BusinessLayer
{
public class CategoryManager : ManagerBase<Category>
{
public override int Delete(Category category)
{
NoteManager noteManager = new NoteManager();
LikedManager likedManager = new LikedManager();
CommentManager commentManager = new CommentManager();

// Kategori ile ilişkili notların silinmesi gerekiyor.
foreach (Note note in category.Notes.ToList())
{

// Note ile ilişikili like'ların silinmesi.
foreach (Liked like in note.Likes.ToList())
{
likedManager.Delete(like);
}

// Note ile ilişkili comment'lerin silinmesi
foreach (Comment comment in note.Commnets.ToList())
{
commentManager.Delete(comment);
}

noteManager.Delete(note);
}

return base.Delete(category);
}
}
}

0 comments on commit da778e4

Please sign in to comment.