Add Category protobuf and CQRS implementation

This commit is contained in:
masoodafar-web
2025-11-27 04:18:35 +03:30
parent c3193824c4
commit ad8d166476
27 changed files with 965 additions and 8 deletions

View File

@@ -23,12 +23,13 @@
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Otp.Protobuf\BackOffice.BFF.Otp.Protobuf.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Protobufs\BackOffice.BFF.User.Protobuf\BackOffice.BFF.User.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserAddress.Protobuf\BackOffice.BFF.UserAddress.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Package.Protobuf\BackOffice.BFF.Package.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Products.Protobuf\BackOffice.BFF.Products.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserOrder.Protobuf\BackOffice.BFF.UserOrder.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Role.Protobuf\BackOffice.BFF.Role.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserRole.Protobuf\BackOffice.BFF.UserRole.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.User.Protobuf\BackOffice.BFF.User.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserAddress.Protobuf\BackOffice.BFF.UserAddress.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Package.Protobuf\BackOffice.BFF.Package.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Products.Protobuf\BackOffice.BFF.Products.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserOrder.Protobuf\BackOffice.BFF.UserOrder.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Role.Protobuf\BackOffice.BFF.Role.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserRole.Protobuf\BackOffice.BFF.UserRole.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Category.Protobuf\BackOffice.BFF.Category.Protobuf.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,45 @@
using BackOffice.BFF.Category.Protobuf.Protos.Category;
using BackOffice.BFF.WebApi.Common.Services;
using BackOffice.BFF.Application.CategoryCQ.Commands.CreateNewCategory;
using BackOffice.BFF.Application.CategoryCQ.Commands.UpdateCategory;
using BackOffice.BFF.Application.CategoryCQ.Commands.DeleteCategory;
using BackOffice.BFF.Application.CategoryCQ.Queries.GetCategory;
using BackOffice.BFF.Application.CategoryCQ.Queries.GetAllCategoryByFilter;
namespace BackOffice.BFF.WebApi.Services;
public class CategoryService : CategoryContract.CategoryContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public CategoryService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewCategoryResponse> CreateNewCategory(CreateNewCategoryRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewCategoryRequest, CreateNewCategoryCommand, CreateNewCategoryResponse>(request, context);
}
public override async Task<Empty> UpdateCategory(UpdateCategoryRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateCategoryRequest, UpdateCategoryCommand>(request, context);
}
public override async Task<Empty> DeleteCategory(DeleteCategoryRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeleteCategoryRequest, DeleteCategoryCommand>(request, context);
}
public override async Task<GetCategoryResponse> GetCategory(GetCategoryRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetCategoryRequest, GetCategoryQuery, GetCategoryResponse>(request, context);
}
public override async Task<GetAllCategoryByFilterResponse> GetAllCategoryByFilter(GetAllCategoryByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllCategoryByFilterRequest, GetAllCategoryByFilterQuery, GetAllCategoryByFilterResponse>(request, context);
}
}