-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from SaintAngeLs/mediafiles_service
Mediafiles service
- Loading branch information
Showing
186 changed files
with
3,736 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
MiniSpace.Services.Events/src/MiniSpace.Services.Events.Application/Events/EventCreated.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Convey.CQRS.Events; | ||
|
||
namespace MiniSpace.Services.Events.Application.Events | ||
{ | ||
public class EventCreated(Guid eventId, Guid organizerId) : IEvent | ||
public class EventCreated(Guid eventId, Guid organizerId, IEnumerable<Guid> mediaFilesIds) : IEvent | ||
{ | ||
public Guid EventId { get; set; } = eventId; | ||
public Guid OrganizerId { get; set; } = organizerId; | ||
public IEnumerable<Guid> MediaFilesIds { get; set; } = mediaFilesIds; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
MiniSpace.Services.Events/src/MiniSpace.Services.Events.Application/Events/EventDeleted.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
MiniSpace.Services.Events/src/MiniSpace.Services.Events.Application/Events/EventUpdated.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Convey.CQRS.Events; | ||
|
||
namespace MiniSpace.Services.Events.Application.Events | ||
{ | ||
public class EventUpdated(Guid eventId, DateTime updatedAt, Guid updatedBy) : IEvent | ||
public class EventUpdated(Guid eventId, DateTime updatedAt, Guid updatedBy, IEnumerable<Guid> mediaFilesIds) : IEvent | ||
{ | ||
public Guid EventId { get; set; } = eventId; | ||
public DateTime UpdatedAt { get; set; } = updatedAt; | ||
public Guid UpdatedBy { get; set; } = updatedBy; | ||
public IEnumerable<Guid> MediaFilesIds { get; set; } = mediaFilesIds; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...MiniSpace.Services.Events.Application/Events/External/Handlers/MediaFileDeletedHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Convey.CQRS.Events; | ||
using MiniSpace.Services.Events.Core.Repositories; | ||
|
||
namespace MiniSpace.Services.Events.Application.Events.External.Handlers | ||
{ | ||
public class MediaFileDeletedHandler: IEventHandler<MediaFileDeleted> | ||
{ | ||
private readonly IEventRepository _eventRepository; | ||
|
||
public MediaFileDeletedHandler(IEventRepository eventRepository) | ||
{ | ||
_eventRepository = eventRepository; | ||
} | ||
|
||
public async Task HandleAsync(MediaFileDeleted @event, CancellationToken cancellationToken) | ||
{ | ||
if(@event.Source.ToLowerInvariant() != "event") | ||
{ | ||
return; | ||
} | ||
|
||
var foundEvent = await _eventRepository.GetAsync(@event.SourceId); | ||
if(foundEvent != null) | ||
{ | ||
foundEvent.RemoveMediaFile(@event.MediaFileId); | ||
await _eventRepository.UpdateAsync(foundEvent); | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ices.Events/src/MiniSpace.Services.Events.Application/Events/External/MediaFileDeleted.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using Convey.CQRS.Events; | ||
using Convey.MessageBrokers; | ||
|
||
namespace MiniSpace.Services.Events.Application.Events.External | ||
{ | ||
[Message("mediafiles")] | ||
public class MediaFileDeleted: IEvent | ||
{ | ||
public Guid MediaFileId { get; } | ||
public Guid SourceId { get; } | ||
public string Source { get; } | ||
|
||
public MediaFileDeleted(Guid mediaFileId, Guid sourceId, string source) | ||
{ | ||
MediaFileId = mediaFileId; | ||
SourceId = sourceId; | ||
Source = source; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...es.Events/src/MiniSpace.Services.Events.Application/Exceptions/InvalidEventIdException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace MiniSpace.Services.Events.Application.Exceptions | ||
{ | ||
public class InvalidEventIdException : AppException | ||
{ | ||
public override string Code { get; } = "invalid_event_id"; | ||
public Guid EventId { get; } | ||
|
||
public InvalidEventIdException(Guid eventId) : base($"Invalid event id: {eventId}.") | ||
{ | ||
EventId = eventId; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...niSpace.Services.Events.Application/Exceptions/InvalidNumberOfEventMediaFilesException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace MiniSpace.Services.Events.Application.Exceptions | ||
{ | ||
public class InvalidNumberOfEventMediaFilesException : AppException | ||
{ | ||
public override string Code { get; } = "invalid_number_of_event_media_files"; | ||
public int MediaFilesNumber { get; } | ||
public InvalidNumberOfEventMediaFilesException(int mediaFilesNumber) | ||
: base($"Invalid media files number: {mediaFilesNumber}. It must be less or equal 5.") | ||
{ | ||
MediaFilesNumber = mediaFilesNumber; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.