mirror of
https://github.com/farcasclaudiu/PracticeCalendar.git
synced 2026-06-22 09:01:18 +03:00
nice refactorings
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace PracticeCalendar.Application.PracticeEvents.Queries
|
||||
{
|
||||
public class AttendeeDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string EmailAddress { get; set; } = string.Empty;
|
||||
public bool IsAttending { get; set; }
|
||||
}
|
||||
}
|
||||
+14
-8
@@ -1,4 +1,6 @@
|
||||
using MediatR;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PracticeCalendar.Domain.Common.Interfaces;
|
||||
using PracticeCalendar.Domain.Entities;
|
||||
@@ -6,27 +8,31 @@ using PracticeCalendar.Domain.Entities.Specifications;
|
||||
|
||||
namespace PracticeCalendar.Application.PracticeEvents.Queries.GetPracticeEvents
|
||||
{
|
||||
public record class GetPracticeEventsQuery : IRequest<List<PracticeEvent>>
|
||||
public record class GetPracticeEventsQuery : IRequest<List<PracticeEventDto>>
|
||||
{
|
||||
}
|
||||
|
||||
public class GetPracticeEventsQueryHandler : IRequestHandler<GetPracticeEventsQuery, List<PracticeEvent>>
|
||||
public class GetPracticeEventsQueryHandler : IRequestHandler<GetPracticeEventsQuery, List<PracticeEventDto>>
|
||||
{
|
||||
private readonly ILogger<GetPracticeEventsQueryHandler> logger;
|
||||
private readonly IRepository<PracticeEvent> eventsRepo;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public GetPracticeEventsQueryHandler(IRepository<PracticeEvent> eventsRepo,
|
||||
ILogger<GetPracticeEventsQueryHandler> logger)
|
||||
public GetPracticeEventsQueryHandler(IRepository<PracticeEvent> eventsRepo,
|
||||
ILogger<GetPracticeEventsQueryHandler> logger,
|
||||
IMapper mapper)
|
||||
{
|
||||
this.eventsRepo = eventsRepo;
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<List<PracticeEvent>> Handle(GetPracticeEventsQuery request, CancellationToken cancellationToken)
|
||||
public async Task<List<PracticeEventDto>> Handle(GetPracticeEventsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var spec = new PracticeEventsWithAttendees();
|
||||
var evList = await eventsRepo.ListAsync(spec);
|
||||
return evList;
|
||||
var evList = await eventsRepo.ListAsync(spec, cancellationToken);
|
||||
var lst = evList.Adapt<List<PracticeEventDto>>(mapper.Config);
|
||||
return lst;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace PracticeCalendar.Application.PracticeEvents.Queries
|
||||
{
|
||||
public class PracticeEventDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
|
||||
public IList<AttendeeDto> Attendees { get; set; } = new List<AttendeeDto>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user