Refactor ShopingCart references and add UserCarts integration
This commit is contained in:
@@ -3,6 +3,7 @@ using CMSMicroservice.Protobuf.Protos.Package;
|
|||||||
using CMSMicroservice.Protobuf.Protos.Products;
|
using CMSMicroservice.Protobuf.Protos.Products;
|
||||||
using CMSMicroservice.Protobuf.Protos.User;
|
using CMSMicroservice.Protobuf.Protos.User;
|
||||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.UserCarts;
|
||||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||||
using PYMSMicroservice.Protobuf.Protos.Transaction;
|
using PYMSMicroservice.Protobuf.Protos.Transaction;
|
||||||
@@ -20,6 +21,7 @@ public interface IApplicationContractContext
|
|||||||
#region CMS
|
#region CMS
|
||||||
PackageContract.PackageContractClient Package { get; }
|
PackageContract.PackageContractClient Package { get; }
|
||||||
ProductsContract.ProductsContractClient Product { get; }
|
ProductsContract.ProductsContractClient Product { get; }
|
||||||
|
UserCartsContract.UserCartsContractClient UserCart { get; }
|
||||||
UserContract.UserContractClient User { get; }
|
UserContract.UserContractClient User { get; }
|
||||||
UserContractContract.UserContractContractClient UserContract { get; }
|
UserContractContract.UserContractContractClient UserContract { get; }
|
||||||
UserAddressContract.UserAddressContractClient UserAddress { get; }
|
UserAddressContract.UserAddressContractClient UserAddress { get; }
|
||||||
|
|||||||
@@ -1,16 +1,32 @@
|
|||||||
|
using CMSMicroservice.Protobuf.Protos.UserCarts;
|
||||||
|
|
||||||
namespace FrontOffice.BFF.Application.ShopingCartCQ.Queries.GetAllUserCart;
|
namespace FrontOffice.BFF.Application.ShopingCartCQ.Queries.GetAllUserCart;
|
||||||
public class GetAllUserCartQueryHandler : IRequestHandler<GetAllUserCartQuery, GetAllUserCartResponseDto>
|
public class GetAllUserCartQueryHandler : IRequestHandler<GetAllUserCartQuery, GetAllUserCartResponseDto>
|
||||||
{
|
{
|
||||||
private readonly IApplicationContractContext _context;
|
private readonly IApplicationContractContext _context;
|
||||||
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
|
||||||
public GetAllUserCartQueryHandler(IApplicationContractContext context)
|
public GetAllUserCartQueryHandler(IApplicationContractContext context, ICurrentUserService currentUserService)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
_currentUserService = currentUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<GetAllUserCartResponseDto> Handle(GetAllUserCartQuery request, CancellationToken cancellationToken)
|
public async Task<GetAllUserCartResponseDto> Handle(GetAllUserCartQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
//TODO: Implement your business logic
|
var userAllCartResponse=await _context.UserCart.GetAllUserCartsByFilterAsync(new GetAllUserCartsByFilterRequest()
|
||||||
|
{
|
||||||
|
Filter = new GetAllUserCartsByFilterFilter()
|
||||||
|
{
|
||||||
|
UserId = long.Parse(_currentUserService.UserId ?? throw new InvalidOperationException())
|
||||||
|
}
|
||||||
|
}, cancellationToken: cancellationToken);
|
||||||
|
if (userAllCartResponse!=null && userAllCartResponse.Models.Count>0)
|
||||||
|
{
|
||||||
|
|
||||||
|
return userAllCartResponse.Adapt<GetAllUserCartResponseDto>();
|
||||||
|
}
|
||||||
|
|
||||||
return new GetAllUserCartResponseDto();
|
return new GetAllUserCartResponseDto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
|
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
|
||||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.121" />
|
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.122" />
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
|
||||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
|
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
|
||||||
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
<PackageReference Include="Grpc.Tools" Version="2.76.0">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using CMSMicroservice.Protobuf.Protos.Package;
|
|||||||
using CMSMicroservice.Protobuf.Protos.Products;
|
using CMSMicroservice.Protobuf.Protos.Products;
|
||||||
using CMSMicroservice.Protobuf.Protos.User;
|
using CMSMicroservice.Protobuf.Protos.User;
|
||||||
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
||||||
|
using CMSMicroservice.Protobuf.Protos.UserCarts;
|
||||||
using CMSMicroservice.Protobuf.Protos.UserContract;
|
using CMSMicroservice.Protobuf.Protos.UserContract;
|
||||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||||
using FrontOffice.BFF.Application.Common.Interfaces;
|
using FrontOffice.BFF.Application.Common.Interfaces;
|
||||||
@@ -44,6 +45,7 @@ public class ApplicationContractContext : IApplicationContractContext
|
|||||||
#region CMS
|
#region CMS
|
||||||
public PackageContract.PackageContractClient Package => GetService<PackageContract.PackageContractClient>();
|
public PackageContract.PackageContractClient Package => GetService<PackageContract.PackageContractClient>();
|
||||||
public ProductsContract.ProductsContractClient Product => GetService<ProductsContract.ProductsContractClient>();
|
public ProductsContract.ProductsContractClient Product => GetService<ProductsContract.ProductsContractClient>();
|
||||||
|
public UserCartsContract.UserCartsContractClient UserCart => GetService<UserCartsContract.UserCartsContractClient>();
|
||||||
|
|
||||||
public UserContract.UserContractClient User => GetService<UserContract.UserContractClient>();
|
public UserContract.UserContractClient User => GetService<UserContract.UserContractClient>();
|
||||||
public UserContractContract.UserContractContractClient UserContract => GetService<UserContractContract.UserContractContractClient>();
|
public UserContractContract.UserContractContractClient UserContract => GetService<UserContractContract.UserContractContractClient>();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<ProjectReference Include="..\FrontOffice.BFF.Application\FrontOffice.BFF.Application.csproj" />
|
<ProjectReference Include="..\FrontOffice.BFF.Application\FrontOffice.BFF.Application.csproj" />
|
||||||
<ProjectReference Include="..\FrontOffice.BFF.Infrastructure\FrontOffice.BFF.Infrastructure.csproj" />
|
<ProjectReference Include="..\FrontOffice.BFF.Infrastructure\FrontOffice.BFF.Infrastructure.csproj" />
|
||||||
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.Products.Protobuf\FrontOffice.BFF.Products.Protobuf.csproj" />
|
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.Products.Protobuf\FrontOffice.BFF.Products.Protobuf.csproj" />
|
||||||
|
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.ShopingCart.Protobuf\FrontOffice.BFF.ShopingCart.Protobuf.csproj" />
|
||||||
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.Transaction.Protobuf\FrontOffice.BFF.Transaction.Protobuf.csproj" />
|
<ProjectReference Include="..\Protobufs\FrontOffice.BFF.Transaction.Protobuf\FrontOffice.BFF.Transaction.Protobuf.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using FrontOffice.BFF.Protobuf.Protos.ShopingCart;
|
|
||||||
using FrontOffice.BFF.WebApi.Common.Services;
|
using FrontOffice.BFF.WebApi.Common.Services;
|
||||||
using FrontOffice.BFF.Application.ShopingCartCQ.Commands.AddNewUserCart;
|
using FrontOffice.BFF.Application.ShopingCartCQ.Commands.AddNewUserCart;
|
||||||
using FrontOffice.BFF.Application.ShopingCartCQ.Queries.GetAllUserCart;
|
using FrontOffice.BFF.Application.ShopingCartCQ.Queries.GetAllUserCart;
|
||||||
using FrontOffice.BFF.Application.ShopingCartCQ.Commands.UpdateUserCart;
|
using FrontOffice.BFF.Application.ShopingCartCQ.Commands.UpdateUserCart;
|
||||||
|
using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart;
|
||||||
|
|
||||||
namespace FrontOffice.BFF.WebApi.Services;
|
namespace FrontOffice.BFF.WebApi.Services;
|
||||||
public class ShopingCartService : ShopingCartContract.ShopingCartContractBase
|
public class ShopingCartService : ShopingCartContract.ShopingCartContractBase
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FrontOffice.BFF.Transaction
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.BFF.Products.Protobuf", "Protobufs\FrontOffice.BFF.Products.Protobuf\FrontOffice.BFF.Products.Protobuf.csproj", "{CB77669F-5B48-4AC6-B20E-A928660E93F8}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.BFF.Products.Protobuf", "Protobufs\FrontOffice.BFF.Products.Protobuf\FrontOffice.BFF.Products.Protobuf.csproj", "{CB77669F-5B48-4AC6-B20E-A928660E93F8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.BFF.ShopingCart.Protobuf", "Protobufs\FrontOffice.BFF.ShopingCart.Protobuf\FrontOffice.BFF.ShopingCart.Protobuf.csproj", "{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -70,6 +72,10 @@ Global
|
|||||||
{CB77669F-5B48-4AC6-B20E-A928660E93F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CB77669F-5B48-4AC6-B20E-A928660E93F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{CB77669F-5B48-4AC6-B20E-A928660E93F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CB77669F-5B48-4AC6-B20E-A928660E93F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{CB77669F-5B48-4AC6-B20E-A928660E93F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CB77669F-5B48-4AC6-B20E-A928660E93F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -81,5 +87,6 @@ Global
|
|||||||
{663CDDFA-E15F-4356-AE01-2311C9B83D52} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
{663CDDFA-E15F-4356-AE01-2311C9B83D52} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
||||||
{F59861D9-01D6-44C9-85A9-E6050D55D290} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
{F59861D9-01D6-44C9-85A9-E6050D55D290} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
||||||
{CB77669F-5B48-4AC6-B20E-A928660E93F8} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
{CB77669F-5B48-4AC6-B20E-A928660E93F8} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
||||||
|
{DC61324B-D389-4A1D-B048-D0AA43A6BBE7} = {CA9BF4D6-6729-4011-888E-48F5F739B469}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FrontOfficeMicroservice.Protobuf.Protos.ShopingCart;
|
using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart;
|
||||||
namespace FrontOfficeMicroservice.Protobuf.Validator.ShopingCart;
|
namespace FrontOfficeMicroservice.Protobuf.Validator.ShopingCart;
|
||||||
|
|
||||||
public class AddNewUserCartRequestValidator : AbstractValidator<AddNewUserCartRequest>
|
public class AddNewUserCartRequestValidator : AbstractValidator<AddNewUserCartRequest>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FrontOfficeMicroservice.Protobuf.Protos.ShopingCart;
|
using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart;
|
||||||
namespace FrontOfficeMicroservice.Protobuf.Validator.ShopingCart;
|
namespace FrontOfficeMicroservice.Protobuf.Validator.ShopingCart;
|
||||||
|
|
||||||
public class UpdateUserCartRequestValidator : AbstractValidator<UpdateUserCartRequest>
|
public class UpdateUserCartRequestValidator : AbstractValidator<UpdateUserCartRequest>
|
||||||
|
|||||||
Reference in New Issue
Block a user