diff --git a/Application/Handlers/CreatePlayOfferHandler.cs b/Application/Handlers/CreatePlayOfferHandler.cs index b41fd73..bcd4688 100644 --- a/Application/Handlers/CreatePlayOfferHandler.cs +++ b/Application/Handlers/CreatePlayOfferHandler.cs @@ -25,6 +25,9 @@ public CreatePlayOfferHandler(WriteEventRepository writeEventRepository, ClubRep public async Task Handle(CreatePlayOfferCommand request, CancellationToken cancellationToken) { var playOfferDto = request.CreatePlayOfferDto; + + if (playOfferDto.ProposedStartTime >= playOfferDto.ProposedEndTime) + throw new InvalidOperationException("Proposed start time must be before proposed end time!"); var club = await _clubRepository.GetClubById(request.ClubId); if (club == null) diff --git a/Application/Handlers/GetPlayOffersByClubIdHandler.cs b/Application/Handlers/GetPlayOffersByClubIdHandler.cs index 3e78837..6ff7de4 100644 --- a/Application/Handlers/GetPlayOffersByClubIdHandler.cs +++ b/Application/Handlers/GetPlayOffersByClubIdHandler.cs @@ -24,8 +24,13 @@ public GetPlayOffersByClubIdHandler(PlayOfferRepository playOfferRepository, Mem public async Task> Handle(GetPlayOffersByClubIdQuery request, CancellationToken cancellationToken) { var playOffers = await _playOfferRepository.GetPlayOffersByIds(null, null, request.ClubId); + var club = await _clubRepository.GetClubById(request.ClubId); - var clubDto = new ClubDto((await _clubRepository.GetClubById(request.ClubId))!); + var playOfferDtos = new List(); + if (club == null) + return playOfferDtos; + + var clubDto = new ClubDto(club); var memberDtos = (await _memberRepository.GetAllMembers()).Select(member => new MemberDto(member)).ToList(); var courtDtos = (await _courtRepository.GetAllCourts()).Select(court => new CourtDto(court)).ToList(); var reservationDtos = (await _reservationRepository.GetAllReservations()) @@ -34,7 +39,7 @@ public async Task> Handle(GetPlayOffersByClubIdQuery r courtDtos.First(courtDto => courtDto.Id == reservation.CourtId))) .ToList(); - var playOfferDtos = new List(); + foreach (var playOffer in playOffers) { var creator = memberDtos.First(member => member.Id == playOffer.CreatorId); diff --git a/Application/RedisPlayOfferStreamService.cs b/Application/RedisPlayOfferStreamService.cs index f1b6d72..0846d6c 100644 --- a/Application/RedisPlayOfferStreamService.cs +++ b/Application/RedisPlayOfferStreamService.cs @@ -53,7 +53,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) var parsedEvent = ParseEvent(streamEntry); await mediator.Send(parsedEvent, _cancellationToken); } - await Task.Delay(1000); + await Task.Delay(250); } } diff --git a/Application/RedisReservationStreamService.cs b/Application/RedisReservationStreamService.cs index 26655e0..f27f941 100644 --- a/Application/RedisReservationStreamService.cs +++ b/Application/RedisReservationStreamService.cs @@ -56,7 +56,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await mediator.Send(parsedEvent, _cancellationToken); } - await Task.Delay(1000); + await Task.Delay(10000); } } diff --git a/Domain/Events/Reservation/ReservationRejectedEvent.cs b/Domain/Events/Reservation/ReservationRejectedEvent.cs index ad4bbb7..dbee749 100644 --- a/Domain/Events/Reservation/ReservationRejectedEvent.cs +++ b/Domain/Events/Reservation/ReservationRejectedEvent.cs @@ -6,17 +6,17 @@ namespace PlayOfferService.Domain.Events.Reservation; public class ReservationRejectedEvent : DomainEvent { [JsonPropertyName("start")] - public DateTime Start { get; set; } + public DateTime? Start { get; set; } [JsonPropertyName("end")] - public DateTime End { get; set; } + public DateTime? End { get; set; } [JsonPropertyName("reservantId")] public Guid? ReservantId { get; set; } [JsonPropertyName("tournamentId")] public Guid? TournamentId { get; set; } [JsonPropertyName("participantIds")] public List? ParticipantIds { get; set; } - [JsonPropertyName("courtIds")] - public Guid CourtId { get; set; } + [JsonPropertyName("courtId")] + public Guid? CourtId { get; set; } public ReservationRejectedEvent(){} } \ No newline at end of file diff --git a/Domain/Models/DTOs/CreatePlayOfferDto.cs b/Domain/Models/DTOs/CreatePlayOfferDto.cs index efa52c8..0bb3890 100644 --- a/Domain/Models/DTOs/CreatePlayOfferDto.cs +++ b/Domain/Models/DTOs/CreatePlayOfferDto.cs @@ -1,7 +1,11 @@ +using System.ComponentModel.DataAnnotations; + namespace PlayOfferService.Domain.Models; public class CreatePlayOfferDto { + [Required] public DateTime ProposedStartTime { get; set; } + [Required] public DateTime ProposedEndTime { get; set; } } \ No newline at end of file diff --git a/Domain/Models/JoinPlayOfferDto.cs b/Domain/Models/JoinPlayOfferDto.cs index 9d2ed93..23e462c 100644 --- a/Domain/Models/JoinPlayOfferDto.cs +++ b/Domain/Models/JoinPlayOfferDto.cs @@ -1,7 +1,11 @@ +using System.ComponentModel.DataAnnotations; + namespace PlayOfferService.Domain.Models; public class JoinPlayOfferDto { + [Required] public Guid PlayOfferId { get; set; } + [Required] public DateTime AcceptedStartTime { get; set; } } \ No newline at end of file