Introduce MassData feature with new API endpoints for querying and upserting records by customer name. Add DTOs, AutoMapper profile, MediatR CQRS handlers, repository pattern, and MassDataDbContext. Register new services in DI and add MassDataConnection to configuration. Upsert uses stored procedure. Enables full CRUD for Massdata via dedicated API.
24 lines
810 B
C#
24 lines
810 B
C#
using AutoMapper;
|
|
using DbFirst.Application.Repositories;
|
|
using MediatR;
|
|
|
|
namespace DbFirst.Application.MassData.Queries;
|
|
|
|
public class GetMassDataByCustomerNameHandler : IRequestHandler<GetMassDataByCustomerNameQuery, MassDataReadDto?>
|
|
{
|
|
private readonly IMassDataRepository _repository;
|
|
private readonly IMapper _mapper;
|
|
|
|
public GetMassDataByCustomerNameHandler(IMassDataRepository repository, IMapper mapper)
|
|
{
|
|
_repository = repository;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
public async Task<MassDataReadDto?> Handle(GetMassDataByCustomerNameQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var item = await _repository.GetByCustomerNameAsync(request.CustomerName, cancellationToken);
|
|
return item == null ? null : _mapper.Map<MassDataReadDto>(item);
|
|
}
|
|
}
|