Dzenis Hadzifejzovic пре 2 година
родитељ
комит
20fe510297

+ 1
- 0
Diligent.WebAPI.Business/MappingProfiles/CategoryMappingProfile.cs Прегледај датотеку

@@ -18,6 +18,7 @@ namespace Diligent.WebAPI.Business.MappingProfiles
#endregion

#region Model to DTO
CreateMap<Category, TreeCategoryItem>();
#endregion
}
}

+ 6
- 0
Diligent.WebAPI.Business/Services/CategoryService.cs Прегледај датотеку

@@ -148,5 +148,11 @@ namespace Diligent.WebAPI.Business.Services

return dto;
}

public async Task<List<TreeCategoryItem>> GetAllCategories()
{
var res = await _context.Categories.Include(k => k.ParentCategory).ToListAsync();
return _mapper.Map<List<TreeCategoryItem>>(res);
}
}
}

+ 1
- 0
Diligent.WebAPI.Business/Services/Interfaces/ICategoryService.cs Прегледај датотеку

@@ -12,5 +12,6 @@ namespace Diligent.WebAPI.Business.Services.Interfaces
Task<CategoriesParentChild> GetRootCategories(int userId,int categoryId);
Task<Category> GetCategoryEntityById(int? id);
Task<List<IsGrantedCategory>> GetCategories(int userId);
Task<List<TreeCategoryItem>> GetAllCategories();
}
}

+ 16
- 0
Diligent.WebAPI.Contracts/DTOs/Categories/TreeCategoryItem.cs Прегледај датотеку

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Contracts.DTOs.Categories
{
public class TreeCategoryItem
{
public int Id { get; set; }

public string Name { get; set; }
public TreeCategoryItem? ParentCategory { get; set; } = null;
}
}

+ 4
- 0
Diligent.WebAPI.Host/Controllers/V1/CategoriesController.cs Прегледај датотеку

@@ -24,5 +24,9 @@ namespace Diligent.WebAPI.Host.Controllers.V1
[HttpGet("granted-categories")]
public async Task<IActionResult> GetCategories(int userId) =>
Ok(await _categoryService.GetCategories(userId));

[HttpGet("all-categories")]
public async Task<IActionResult> GetAllCategories() =>
Ok(await _categoryService.GetAllCategories());
}
}

Loading…
Откажи
Сачувај