public async Task <List <AllCategoriesNameDto> > GetCategoryTree(int?parentId = null)
            {
                List <AllCategoriesNameDto> absoluteCategories = new List <AllCategoriesNameDto>();

                List <Category> categories = await _context.Category
                                             .Where(x => !x.IsDelete)
                                             .ToListAsync();

                if (categories.Count <= 0)
                {
                    return(absoluteCategories);
                }

                List <Category> subCategories = categories
                                                .Where(x => x.ParentCategoryId == parentId)
                                                .OrderBy(x => x.Sort)
                                                .ToList();

                foreach (Category subCategory in subCategories)
                {
                    List <Tuple <int, int?> > previousCategories = new List <Tuple <int, int?> >();

                    AllCategoryNameAbstractDto category = new AllCategoryNameAbstractDto
                    {
                        Id       = subCategory.CategoryId,
                        Guid     = subCategory.CategoryGuid,
                        ParentId = subCategory.ParentCategoryId,
                        Title    = subCategory.DisplayName,
                        Sort     = subCategory.Sort
                    };

                    absoluteCategories.Add(new AllCategoriesNameDto()
                    {
                        Guid = category.Guid, Name = category.Title
                    });
                    previousCategories.Add(new Tuple <int, int?>(category.Id, category.ParentId));

                    category.SubCategories = await GetCategoryChildren(categories, category, previousCategories, absoluteCategories);
                }

                return(absoluteCategories);
            }
            private static async Task <List <AllCategoryNameAbstractDto> > GetCategoryChildren(List <Category> categories,
                                                                                               AllCategoryNameAbstractDto category,
                                                                                               List <Tuple <int, int?> > previousCategories,
                                                                                               List <AllCategoriesNameDto> absoluteCategories)
            {
                List <AllCategoryNameAbstractDto> subCategories = categories
                                                                  .Where(x => x.ParentCategoryId == category.Id)
                                                                  .OrderBy(x => x.Sort)
                                                                  .Select(x => new AllCategoryNameAbstractDto
                {
                    Id       = x.CategoryId,
                    Guid     = x.CategoryGuid,
                    ParentId = x.ParentCategoryId,
                    Title    = x.DisplayName,
                    Sort     = x.Sort
                }).ToList();

                if (subCategories.Count <= 0)
                {
                    return(null);
                }

                category.SubCategories = subCategories;

                foreach (AllCategoryNameAbstractDto subCategory in category.SubCategories)
                {
                    if (subCategory.ParentId == previousCategories[^ 1].Item1)
                    {
                        absoluteCategories.Add(new AllCategoriesNameDto()
                        {
                            Guid = subCategory.Guid, Name = absoluteCategories[^ 1].Name + $", {subCategory.Title}"