Add validators and services for Product Galleries and Product Tags
- Implemented Create, Delete, Get, and Update validators for Product Galleries. - Added Create, Delete, Get, and Update validators for Product Tags. - Created service classes for handling Discount Categories, Discount Orders, Discount Products, Discount Shopping Cart, Product Categories, Product Galleries, and Product Tags. - Each service class integrates with CQRS for command and query handling. - Established mapping profiles for Product Galleries.
This commit is contained in:
@@ -1,10 +1,40 @@
|
||||
using CMSMicroservice.Application.TagCQ.Queries.GetProductsByTag;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||
|
||||
public class TagProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
//config.NewConfig<Source,Destination>()
|
||||
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
|
||||
// GetProductsByTagRequest -> GetProductsByTagQuery
|
||||
config.NewConfig<GetProductsByTagRequest, GetProductsByTagQuery>()
|
||||
.Map(dest => dest.TagId, src => src.TagId);
|
||||
|
||||
// List<ProductSimpleDto> -> GetProductsByTagResponse
|
||||
config.NewConfig<List<ProductSimpleDto>, GetProductsByTagResponse>()
|
||||
.MapWith(src => ConvertToResponse(src));
|
||||
}
|
||||
|
||||
private static GetProductsByTagResponse ConvertToResponse(List<ProductSimpleDto> products)
|
||||
{
|
||||
var response = new GetProductsByTagResponse();
|
||||
|
||||
foreach (var product in products)
|
||||
{
|
||||
response.Products.Add(new ProductSimpleModel
|
||||
{
|
||||
Id = product.Id,
|
||||
Title = product.Title,
|
||||
Price = product.Price,
|
||||
Inventory = product.Inventory,
|
||||
IsActive = product.IsActive,
|
||||
ImagePath = product.ImagePath
|
||||
});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user