Skip to content

Commit

Permalink
(#412) events: update delete event and event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Sep 16, 2024
1 parent 74c3931 commit d6f5bb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ public async Task HandleAsync(DeleteEvent command, CancellationToken cancellatio
}

await _eventRepository.DeleteAsync(command.EventId);
await _messageBroker.PublishAsync(new EventDeleted(command.EventId));

var organizerId = @event.Organizer.OrganizerType == OrganizerType.User
? @event.Organizer.UserId.GetValueOrDefault()
: @event.Organizer.OrganizationId.GetValueOrDefault();

await _messageBroker.PublishAsync(new EventDeleted(
command.EventId,
@event.Name,
organizerId,
@event.StartDate,
@event.EndDate
));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
using System;
using System.Collections.Generic;
using Convey.CQRS.Events;

namespace MiniSpace.Services.Events.Application.Events
{
public class EventDeleted(Guid eventId) : IEvent
public class EventDeleted : IEvent
{
public Guid EventId { get; set; } = eventId;
public Guid EventId { get; }
public string EventName { get; }
public Guid OrganizerId { get; }
public DateTime StartDate { get; }
public DateTime EndDate { get; }

public EventDeleted(Guid eventId, string eventName, Guid organizerId, DateTime startDate, DateTime endDate)
{
EventId = eventId;
EventName = eventName;
OrganizerId = organizerId;
StartDate = startDate;
EndDate = endDate;
}
}
}
}

0 comments on commit d6f5bb1

Please sign in to comment.