From ca73dc7e8487ace14e3e33e5b82c9961bc60c274 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Mon, 21 Dec 2020 21:25:21 +0330 Subject: [PATCH] #53 cat parents --- RMuseum/Services/Implementation/GanjoorService.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index d23290df..0a3361d9 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -91,6 +91,16 @@ namespace RMuseum.Services.Implementation if (cat == null) return new RServiceResult(null); + if(cat.Parent != null) + { + var parent = cat.Parent; + while(parent.ParentId != null) + { + parent.Parent = await _context.GanjoorCategories.Where(c => c.Id == parent.ParentId).FirstOrDefaultAsync(); + parent = parent.Parent; + } + } + return new RServiceResult ( new GanjoorPoetCompleteViewModel()