Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using TickAPI.Categories.Models;
using TickAPI.Common.Results.Generic;

namespace TickAPI.Categories.Abstractions;

public interface ICategoryRepository
{
public Task<Result<IEnumerable<Category>>> GetCategoriesAsync();
}
9 changes: 9 additions & 0 deletions TickAPI/TickAPI/Categories/Abstractions/ICategoryService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using TickAPI.Categories.Models;
using TickAPI.Common.Results.Generic;

namespace TickAPI.Categories.Abstractions;

public interface ICategoryService
{
public Task<Result<IEnumerable<Category>>> GetCategoriesAsync();
}
29 changes: 29 additions & 0 deletions TickAPI/TickAPI/Categories/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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;

[ApiController]
[Route("api/[controller]")]

public class CategoryController : Controller
{

private readonly ICategoryService _categoryService;

public CategoryController(ICategoryService categoryService)
{
_categoryService = categoryService;
}

[AuthorizeWithPolicy(AuthPolicies.VerifiedOrganizerPolicy)]
[HttpPost("get-categories")]
public async Task<IEnumerable<Category>> GetCategories()
{
throw new NotImplementedException();
}
}
21 changes: 21 additions & 0 deletions TickAPI/TickAPI/Categories/Respositories/CategoryRepository.cs
Original file line number Diff line number Diff line change
@@ -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<Result<IEnumerable<Category>>> GetCategoriesAsync()
{
throw new NotImplementedException();
}
}
20 changes: 20 additions & 0 deletions TickAPI/TickAPI/Categories/Services/CategoryService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using TickAPI.Categories.Abstractions;
using TickAPI.Categories.Models;
using TickAPI.Common.Results.Generic;

namespace TickAPI.Categories.Services;

public class CategoryService : ICategoryService
{
private readonly ICategoryRepository _categoryRepository;

public CategoryService(ICategoryRepository categoryRepository)
{
_categoryRepository = categoryRepository;
}

public Task<Result<IEnumerable<Category>>> GetCategoriesAsync()
{
throw new NotImplementedException();
}
}
7 changes: 7 additions & 0 deletions TickAPI/TickAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -47,8 +50,8 @@
})
.AddGoogle(options =>
{
options.ClientId = builder.Configuration["Authentication:Google:ClientId"];

Check warning on line 53 in TickAPI/TickAPI/Program.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.
options.ClientSecret = builder.Configuration["Authentication:Google:ClientSecret"];

Check warning on line 54 in TickAPI/TickAPI/Program.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.
})
.AddJwtBearer(options =>
{
Expand All @@ -60,7 +63,7 @@
ValidateIssuerSigningKey = true,
ValidIssuer = builder.Configuration["Authentication:Jwt:Issuer"],
IssuerSigningKey = new SymmetricSecurityKey(
Encoding.UTF8.GetBytes(builder.Configuration["Authentication:Jwt:SecurityKey"]))

Check warning on line 66 in TickAPI/TickAPI/Program.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 's' in 'byte[] Encoding.GetBytes(string s)'.
};
});

Expand Down Expand Up @@ -99,6 +102,10 @@
builder.Services.AddScoped<ITicketService, TicketService>();
builder.Services.AddScoped<ITicketRepository, TicketRepository>();

// Add category services.
builder.Services.AddScoped<ICategoryService, CategoryService>();
builder.Services.AddScoped<ICategoryRepository, CategoryRepository>();

// Add common services.
builder.Services.AddScoped<IGoogleAuthService, GoogleAuthService>();
builder.Services.AddScoped<IJwtService, JwtService>();
Expand Down
Loading