Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Application/Handlers/CreatePlayOfferHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public CreatePlayOfferHandler(WriteEventRepository writeEventRepository, ClubRep
public async Task<Guid> 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)
Expand Down
9 changes: 7 additions & 2 deletions Application/Handlers/GetPlayOffersByClubIdHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ public GetPlayOffersByClubIdHandler(PlayOfferRepository playOfferRepository, Mem
public async Task<IEnumerable<PlayOfferDto>> 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<PlayOfferDto>();
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())
Expand All @@ -34,7 +39,7 @@ public async Task<IEnumerable<PlayOfferDto>> Handle(GetPlayOffersByClubIdQuery r
courtDtos.First(courtDto => courtDto.Id == reservation.CourtId)))
.ToList();

var playOfferDtos = new List<PlayOfferDto>();

foreach (var playOffer in playOffers)
{
var creator = memberDtos.First(member => member.Id == playOffer.CreatorId);
Expand Down
2 changes: 1 addition & 1 deletion Application/RedisPlayOfferStreamService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Application/RedisReservationStreamService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

await mediator.Send(parsedEvent, _cancellationToken);
}
await Task.Delay(1000);
await Task.Delay(10000);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Domain/Events/Reservation/ReservationRejectedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Guid>? ParticipantIds { get; set; }
[JsonPropertyName("courtIds")]
public Guid CourtId { get; set; }
[JsonPropertyName("courtId")]
public Guid? CourtId { get; set; }

public ReservationRejectedEvent(){}
}
4 changes: 4 additions & 0 deletions Domain/Models/DTOs/CreatePlayOfferDto.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
4 changes: 4 additions & 0 deletions Domain/Models/JoinPlayOfferDto.cs
Original file line number Diff line number Diff line change
@@ -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; }
}