From 466324fb47b84709f0621e98afc82c9b548f0a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw?= <62651497+staszkiet@users.noreply.github.com> Date: Sun, 30 Mar 2025 15:21:15 +0200 Subject: [PATCH 1/2] Add service repository and controller classes to categories folder --- .../Abstractions/ICategoryRepository.cs | 9 ++++++++ .../Abstractions/ICategoryService.cs | 9 ++++++++ .../Controllers/CategoryController.cs | 16 ++++++++++++++ .../Respositories/CategoryRepository.cs | 21 +++++++++++++++++++ .../Categories/Services/CategoryService.cs | 20 ++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 TickAPI/TickAPI/Categories/Abstractions/ICategoryRepository.cs create mode 100644 TickAPI/TickAPI/Categories/Abstractions/ICategoryService.cs create mode 100644 TickAPI/TickAPI/Categories/Controllers/CategoryController.cs create mode 100644 TickAPI/TickAPI/Categories/Respositories/CategoryRepository.cs create mode 100644 TickAPI/TickAPI/Categories/Services/CategoryService.cs diff --git a/TickAPI/TickAPI/Categories/Abstractions/ICategoryRepository.cs b/TickAPI/TickAPI/Categories/Abstractions/ICategoryRepository.cs new file mode 100644 index 0000000..1e5d8cb --- /dev/null +++ b/TickAPI/TickAPI/Categories/Abstractions/ICategoryRepository.cs @@ -0,0 +1,9 @@ +using TickAPI.Categories.Models; +using TickAPI.Common.Results.Generic; + +namespace TickAPI.Categories.Abstractions; + +public interface ICategoryRepository +{ + public Task>> GetCategoriesAsync(); +} \ No newline at end of file diff --git a/TickAPI/TickAPI/Categories/Abstractions/ICategoryService.cs b/TickAPI/TickAPI/Categories/Abstractions/ICategoryService.cs new file mode 100644 index 0000000..dc74fc2 --- /dev/null +++ b/TickAPI/TickAPI/Categories/Abstractions/ICategoryService.cs @@ -0,0 +1,9 @@ +using TickAPI.Categories.Models; +using TickAPI.Common.Results.Generic; + +namespace TickAPI.Categories.Abstractions; + +public interface ICategoryService +{ + public Task>> GetCategoriesAsync(); +} \ No newline at end of file diff --git a/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs b/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs new file mode 100644 index 0000000..3ffb38a --- /dev/null +++ b/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; +using TickAPI.Categories.Models; + +namespace TickAPI.Categories.Controllers; + +[ApiController] +[Route("api/[controller]")] + +public class CategoryController : Controller +{ + [HttpPost("get-categories")] + public async Task> GetCategories() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/TickAPI/TickAPI/Categories/Respositories/CategoryRepository.cs b/TickAPI/TickAPI/Categories/Respositories/CategoryRepository.cs new file mode 100644 index 0000000..7bc9346 --- /dev/null +++ b/TickAPI/TickAPI/Categories/Respositories/CategoryRepository.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using TickAPI.Categories.Abstractions; +using TickAPI.Categories.Models; +using TickAPI.Common.Results.Generic; +using TickAPI.Common.TickApiDbContext; +namespace TickAPI.Categories.Respositories; + +public class CategoryRepository : ICategoryRepository +{ + private readonly TickApiDbContext _tickApiDbContext; + + public CategoryRepository(TickApiDbContext tickApiDbContext) + { + _tickApiDbContext = tickApiDbContext; + } + + public async Task>> GetCategoriesAsync() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/TickAPI/TickAPI/Categories/Services/CategoryService.cs b/TickAPI/TickAPI/Categories/Services/CategoryService.cs new file mode 100644 index 0000000..3e20024 --- /dev/null +++ b/TickAPI/TickAPI/Categories/Services/CategoryService.cs @@ -0,0 +1,20 @@ +using TickAPI.Categories.Abstractions; +using TickAPI.Categories.Models; +using TickAPI.Common.Results.Generic; + +namespace TickAPI.Categories.Services; + +public class CategoryService : ICategoryRepository +{ + private readonly ICategoryRepository _categoryRepository; + + public CategoryService(ICategoryRepository categoryRepository) + { + _categoryRepository = categoryRepository; + } + + public Task>> GetCategoriesAsync() + { + throw new NotImplementedException(); + } +} \ No newline at end of file From 60544d2d6736d4ff2bf518e91141b44e6765b8c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw?= <62651497+staszkiet@users.noreply.github.com> Date: Sun, 30 Mar 2025 15:22:40 +0200 Subject: [PATCH 2/2] Add missing files --- .../Categories/Controllers/CategoryController.cs | 13 +++++++++++++ .../TickAPI/Categories/Services/CategoryService.cs | 2 +- TickAPI/TickAPI/Program.cs | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs b/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs index 3ffb38a..4037416 100644 --- a/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs +++ b/TickAPI/TickAPI/Categories/Controllers/CategoryController.cs @@ -1,5 +1,9 @@ using Microsoft.AspNetCore.Mvc; +using TickAPI.Categories.Abstractions; using TickAPI.Categories.Models; +using TickAPI.Common.Auth.Attributes; +using TickAPI.Common.Auth.Enums; +using TickAPI.Customers.Abstractions; namespace TickAPI.Categories.Controllers; @@ -8,6 +12,15 @@ namespace TickAPI.Categories.Controllers; public class CategoryController : Controller { + + private readonly ICategoryService _categoryService; + + public CategoryController(ICategoryService categoryService) + { + _categoryService = categoryService; + } + + [AuthorizeWithPolicy(AuthPolicies.VerifiedOrganizerPolicy)] [HttpPost("get-categories")] public async Task> GetCategories() { diff --git a/TickAPI/TickAPI/Categories/Services/CategoryService.cs b/TickAPI/TickAPI/Categories/Services/CategoryService.cs index 3e20024..addb0de 100644 --- a/TickAPI/TickAPI/Categories/Services/CategoryService.cs +++ b/TickAPI/TickAPI/Categories/Services/CategoryService.cs @@ -4,7 +4,7 @@ namespace TickAPI.Categories.Services; -public class CategoryService : ICategoryRepository +public class CategoryService : ICategoryService { private readonly ICategoryRepository _categoryRepository; diff --git a/TickAPI/TickAPI/Program.cs b/TickAPI/TickAPI/Program.cs index 2b0ffca..d4110fa 100644 --- a/TickAPI/TickAPI/Program.cs +++ b/TickAPI/TickAPI/Program.cs @@ -30,6 +30,9 @@ using TickAPI.Addresses.Abstractions; using TickAPI.Addresses.Repositories; using TickAPI.Addresses.Services; +using TickAPI.Categories.Abstractions; +using TickAPI.Categories.Respositories; +using TickAPI.Categories.Services; // Builder constants const string allowClientPolicyName = "AllowClient"; @@ -99,6 +102,10 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); +// Add category services. +builder.Services.AddScoped(); +builder.Services.AddScoped(); + // Add common services. builder.Services.AddScoped(); builder.Services.AddScoped();