Holy moly......
This commit is contained in:
26
src/Imprink.Application/Commands/Addresses/GetMyAddresses.cs
Normal file
26
src/Imprink.Application/Commands/Addresses/GetMyAddresses.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using AutoMapper;
|
||||
using Imprink.Application.Dtos;
|
||||
using Imprink.Application.Services;
|
||||
using Imprink.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace Imprink.Application.Commands.Addresses;
|
||||
|
||||
public class GetMyAddressesQuery : IRequest<IEnumerable<AddressDto?>>;
|
||||
|
||||
public class GetMyAddresses(
|
||||
IUnitOfWork uw,
|
||||
IMapper mapper,
|
||||
ICurrentUserService userService)
|
||||
: IRequestHandler<GetMyAddressesQuery, IEnumerable<AddressDto?>>
|
||||
{
|
||||
public async Task<IEnumerable<AddressDto?>> Handle(
|
||||
GetMyAddressesQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<Address?> addresses = await uw.AddressRepository
|
||||
.GetByUserIdAsync(userService.GetCurrentUserId(), cancellationToken);
|
||||
|
||||
return mapper.Map<IEnumerable<AddressDto>>(addresses);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user