Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/APITemplate/Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using JasperFx;
using JasperFx.Resources;
using ProductCatalog;
using ProductCatalog.Features.CreateProducts;
using ProductCatalog.Features.Product.CreateProducts;
using ProductCatalog.Handlers;
using Reviews;
using Reviews.Features;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using SharedKernel.Contracts.Api;
using Wolverine;

namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed partial class CategoriesController(IMessageBus bus) : ApiControllerBase { }
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using ProductCatalog.Features.Category.CreateCategories;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.CreateCategories;
namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed class CreateCategoriesController(IMessageBus bus) : ApiControllerBase
public sealed partial class CategoriesController
{
/// <summary>Creates multiple categories in a single batch operation.</summary>
[HttpPost]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Wolverine;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.CreateCategories;
namespace ProductCatalog.Features.Category.CreateCategories;

/// <summary>Creates multiple categories in a single batch operation.</summary>
public sealed record CreateCategoriesCommand(CreateCategoriesRequest Request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;

namespace ProductCatalog.Features.CreateCategories;
namespace ProductCatalog.Features.Category.CreateCategories;

/// <summary>
/// Carries a list of category items to be created in a single batch operation; accepts between 1 and 100 items.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using SharedKernel.Application.Validation;

namespace ProductCatalog.Features.CreateCategories;
namespace ProductCatalog.Features.Category.CreateCategories;

/// <summary>
/// Payload for creating a new category, carrying the name and optional description.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SharedKernel.Application.Validation;

namespace ProductCatalog.Features.CreateCategories;
namespace ProductCatalog.Features.Category.CreateCategories;

/// <summary>
/// FluentValidation validator for <see cref="CreateCategoryRequest"/> that enforces data-annotation constraints.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using ProductCatalog.Features.Category.DeleteCategories;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.DeleteCategories;
namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed class DeleteCategoriesController(IMessageBus bus) : ApiControllerBase
public sealed partial class CategoriesController
{
/// <summary>Soft-deletes multiple categories in a single batch operation.</summary>
[HttpDelete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using ProductCatalog;
using Wolverine;

namespace ProductCatalog.Features.DeleteCategories;
namespace ProductCatalog.Features.Category.DeleteCategories;

/// <summary>Soft-deletes multiple categories in a single batch operation.</summary>
public sealed record DeleteCategoriesCommand(BatchDeleteRequest Request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using ProductCatalog.Features.Category.GetCategories;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.GetCategories;
namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed class GetCategoriesController(IMessageBus bus) : ApiControllerBase
public sealed partial class CategoriesController
{
/// <summary>Returns a paginated, filterable list of categories from the output cache.</summary>
[HttpGet]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SharedKernel.Application.Contracts;
using SharedKernel.Application.DTOs;

namespace ProductCatalog.Features.GetCategories;
namespace ProductCatalog.Features.Category.GetCategories;

/// <summary>
/// Filter parameters for querying categories, supporting full-text search, sorting, and pagination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.EntityFrameworkCore;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.GetCategories;
namespace ProductCatalog.Features.Category.GetCategories;

/// <summary>
/// Extension methods that apply <see cref="CategoryFilter"/> search criteria to an Ardalis specification builder.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SharedKernel.Application.Validation;
using FluentValidation;

namespace ProductCatalog.Features.GetCategories;
namespace ProductCatalog.Features.Category.GetCategories;

/// <summary>
/// FluentValidation validator for <see cref="CategoryFilter"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Ardalis.Specification;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.GetCategories;
namespace ProductCatalog.Features.Category.GetCategories;

/// <summary>
/// Ardalis specification for querying a filtered and sorted list of categories projected to <see cref="CategoryResponse"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ErrorOr;

namespace ProductCatalog.Features.GetCategories;
namespace ProductCatalog.Features.Category.GetCategories;

/// <summary>Returns a paginated, filtered, and sorted list of categories.</summary>
public sealed record GetCategoriesQuery(CategoryFilter Filter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using ProductCatalog.Features.Category.GetCategoryById;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.GetCategoryById;
namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed class GetCategoryByIdController(IMessageBus bus) : ApiControllerBase
public sealed partial class CategoriesController
{
/// <summary>Returns a single category by its identifier, or 404 if not found.</summary>
[HttpGet("{id:guid}")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Ardalis.Specification;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.GetCategoryById;
namespace ProductCatalog.Features.Category.GetCategoryById;

/// <summary>
/// Ardalis specification that fetches a single category by its identifier, projected directly to <see cref="CategoryResponse"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ErrorOr;
using ProductCatalog.Interfaces;

namespace ProductCatalog.Features.GetCategoryById;
namespace ProductCatalog.Features.Category.GetCategoryById;

/// <summary>Returns a single category by its unique identifier, or <see langword="null"/> if not found.</summary>
public sealed record GetCategoryByIdQuery(Guid Id) : IHasId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching;
using ProductCatalog.Features.Category.GetCategoryStats;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.GetCategoryStats;
namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed class GetCategoryStatsController(IMessageBus bus) : ApiControllerBase
public sealed partial class CategoriesController
{
/// <summary>
/// Returns aggregated statistics for a category by calling the
/// <c>get_product_category_stats(p_category_id)</c> stored procedure via EF Core FromSql.
/// Returns aggregated statistics for a category via
/// <c>get_product_category_stats(p_category_id)</c> (EF Core FromSql).
/// </summary>
[HttpGet("{id:guid}/stats")]
[RequirePermission(Permission.Categories.Read)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using ProductCatalog.Interfaces;
using ProductCategoryStatsEntity = ProductCatalog.Entities.ProductCategoryStats;

namespace ProductCatalog.Features.GetCategoryStats;
namespace ProductCatalog.Features.Category.GetCategoryStats;

/// <summary>Returns aggregated statistics for a category by its identifier, or <see langword="null"/> if not found.</summary>
public sealed record GetCategoryStatsQuery(Guid Id) : IHasId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ProductCatalog.Features.GetCategoryStats;
namespace ProductCatalog.Features.Category.GetCategoryStats;

/// <summary>
/// Aggregated statistics for a single category, including product count, average price, and total review count.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Ardalis.Specification;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.Shared;
namespace ProductCatalog.Features.Category.Shared;

/// <summary>
/// Ardalis specification that loads multiple categories by their IDs, used for batch update and delete operations.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.Shared;
namespace ProductCatalog.Features.Category.Shared;

/// <summary>
/// Provides mapping utilities between category domain entities and their response DTOs.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ProductCatalog.Features.Shared;
namespace ProductCatalog.Features.Category.Shared;

/// <summary>
/// Read model returned by category queries, containing the public-facing representation of a category.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SharedKernel.Application.Sorting;
using CategoryEntity = ProductCatalog.Entities.Category;

namespace ProductCatalog.Features.Shared;
namespace ProductCatalog.Features.Category.Shared;

/// <summary>
/// Defines the allowed sort fields for category queries and maps them to entity expressions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using ProductCatalog.Features.Category.UpdateCategories;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.UpdateCategories;
namespace ProductCatalog.Features.Category;

[ApiVersion(1.0)]
public sealed class UpdateCategoriesController(IMessageBus bus) : ApiControllerBase
public sealed partial class CategoriesController
{
/// <summary>Updates multiple categories in a single batch operation.</summary>
[HttpPut]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using SharedKernel.Contracts.Events;
using Wolverine;

namespace ProductCatalog.Features.UpdateCategories;
namespace ProductCatalog.Features.Category.UpdateCategories;

/// <summary>Updates multiple categories in a single batch operation.</summary>
public sealed record UpdateCategoriesCommand(UpdateCategoriesRequest Request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using SharedKernel.Application.Validation;

namespace ProductCatalog.Features.UpdateCategories;
namespace ProductCatalog.Features.Category.UpdateCategories;

/// <summary>
/// Carries a list of category items to be updated in a single batch operation; accepts between 1 and 100 items.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SharedKernel.Application.Validation;

namespace ProductCatalog.Features.UpdateCategories;
namespace ProductCatalog.Features.Category.UpdateCategories;

/// <summary>
/// FluentValidation validator for <see cref="UpdateCategoryItem"/> that enforces data-annotation constraints.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ProductCatalog.Features.UpdateCategories;
namespace ProductCatalog.Features.Category.UpdateCategories;

/// <summary>
/// Payload for updating an existing category's name and optional description.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;

namespace ProductCatalog.Features.CreateProducts;
namespace ProductCatalog.Features.Product.CreateProducts;

/// <summary>
/// Carries the data required to create a new product, including validation constraints enforced via data annotations.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ProductCatalog.Features.CreateProducts;
namespace ProductCatalog.Features.Product.CreateProducts;

/// <summary>
/// FluentValidation validator for <see cref="CreateProductRequest"/>, inheriting all rules from <see cref="ProductRequestValidatorBase{T}"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using ProductEntity = ProductCatalog.Entities.Product;
using ProductRepositoryContract = ProductCatalog.Interfaces.IProductRepository;

namespace ProductCatalog.Features.CreateProducts;
namespace ProductCatalog.Features.Product.CreateProducts;

/// <summary>Creates multiple products in a single batch operation.</summary>
public sealed record CreateProductsCommand(CreateProductsRequest Request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;

namespace ProductCatalog.Features.CreateProducts;
namespace ProductCatalog.Features.Product.CreateProducts;

/// <summary>
/// Carries a list of product items to be created in a single batch operation; accepts between 1 and 100 items.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using ProductCatalog.Features.Product.CreateProducts;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.CreateProducts;
namespace ProductCatalog.Features.Product;

[ApiVersion(1.0)]
public sealed class CreateProductsController(IMessageBus bus) : ApiControllerBase
public sealed partial class ProductsController
{
/// <summary>Creates multiple products in a single batch operation.</summary>
[HttpPost]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Wolverine;
using ProductRepositoryContract = ProductCatalog.Interfaces.IProductRepository;

namespace ProductCatalog.Features.DeleteProducts;
namespace ProductCatalog.Features.Product.DeleteProducts;

/// <summary>Soft-deletes multiple products and their associated data links in a single batch operation.</summary>
public sealed record DeleteProductsCommand(BatchDeleteRequest Request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Asp.Versioning;
using ErrorOr;
using Microsoft.AspNetCore.Mvc;
using ProductCatalog.Features.Product.DeleteProducts;
using SharedKernel.Contracts.Api;
using SharedKernel.Contracts.Security;
using Wolverine;

namespace ProductCatalog.Features.DeleteProducts;
namespace ProductCatalog.Features.Product;

[ApiVersion(1.0)]
public sealed class DeleteProductsController(IMessageBus bus) : ApiControllerBase
public sealed partial class ProductsController
{
/// <summary>Soft-deletes multiple products in a single batch operation.</summary>
[HttpDelete]
Expand Down
Loading
Loading