diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/CancelArtEventCommandHandler.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/CancelArtEventCommandHandler.cs index 2a21dd5..dc35af4 100644 --- a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/CancelArtEventCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/CancelArtEventCommandHandler.cs @@ -1,9 +1,11 @@ using MediatR; using PERUSTARS.AtEventManagement.Domain.Model.Aggregates; using PERUSTARS.AtEventManagement.Domain.Model.Commads; +using PERUSTARS.AtEventManagement.Domain.Model.domainevents; using PERUSTARS.AtEventManagement.Domain.Model.Repositories; using PERUSTARS.AtEventManagement.Domain.Model.ValueObjects; using PERUSTARS.Shared.Domain.Repositories; +using System; using System.Threading; using System.Threading.Tasks; @@ -13,10 +15,12 @@ public class CancelArtEventCommandHandler : IRequestHandler Handle(CancelArtEventCommand request, CancellationToken cancellationToken) @@ -24,10 +28,21 @@ public async Task Handle(CancelArtEventCommand request, CancellationToke ArtEvent artEvent = _artEventRepository.FindByIdAsync(request.id).Result; if (artEvent != null) { - artEvent.CurrentStatus = ArtEventStatus.CANCELLED; - _artEventRepository.Update(artEvent); - await _unitOfWork.CompleteAsync(); - return "Event updated!!!"; + + artEvent.CurrentStatus = ArtEventStatus.CANCELLED; + _artEventRepository.Update(artEvent); + await _publisher.Publish(new ArtEventCancelledEvent() + { + Title = artEvent.Title, + Description = artEvent.Description, + Location = artEvent.Location, + EndDate = DateTime.Now, + CurrentStatus = ArtEventStatus.CANCELLED, + StartDate = (DateTime)artEvent.StartDateTime + }); + await _unitOfWork.CompleteAsync(); + return "Event updated!!!"; + } else { return "The event with the given id doesn't exist"; diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/RescheduleArtEventCommandHandler.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/RescheduleArtEventCommandHandler.cs index 0773b27..d0698d9 100644 --- a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/RescheduleArtEventCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/RescheduleArtEventCommandHandler.cs @@ -1,6 +1,7 @@ using MediatR; using PERUSTARS.AtEventManagement.Domain.Model.Aggregates; using PERUSTARS.AtEventManagement.Domain.Model.Commads; +using PERUSTARS.AtEventManagement.Domain.Model.domainevents; using PERUSTARS.AtEventManagement.Domain.Model.Repositories; using PERUSTARS.AtEventManagement.Domain.Model.ValueObjects; using PERUSTARS.Shared.Domain.Repositories; @@ -13,10 +14,12 @@ public class RescheduleArtEventCommandHandler : IRequestHandler Handle(RescheduleArtEventCommand request, CancellationToken cancellationToken) { @@ -27,6 +30,14 @@ public async Task Handle(RescheduleArtEventCommand request, Cancellation artEvent.CurrentStatus = ArtEventStatus.RESCHEDULED; _artEventRepository.Update(artEvent); await _unitOfWork.CompleteAsync(); + await _publisher.Publish(new ArtEventRescheduledEvent() + { + Title = artEvent.Title, + Description = artEvent.Description, + CurrentStatus = ArtEventStatus.RESCHEDULED, + StartDate = (System.DateTime)artEvent.StartDateTime, + Location = artEvent.Location + }); return "Art Event rescheduled!!"; } else { diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/StartArtEventCommandHandler.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/StartArtEventCommandHandler.cs index 0e24664..c458763 100644 --- a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/StartArtEventCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/commands/StartArtEventCommandHandler.cs @@ -30,6 +30,8 @@ public async Task Handle(StartArtEventCommand request, CancellationToken else { artEvent.CurrentStatus = ArtEventStatus.STARTED; + _artEventRepository.Update(artEvent); + _unitOfWork.CompleteAsync(); return "Event started!!"; } diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/events/ArtEventRescheduledEventHandler.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/events/ArtEventRescheduledEventHandler.cs new file mode 100644 index 0000000..2ab4299 --- /dev/null +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/events/ArtEventRescheduledEventHandler.cs @@ -0,0 +1,28 @@ +using MediatR; +using PERUSTARS.AtEventManagement.Domain.Model.domainevents; +using PERUSTARS.CommunicationAndNotificationManagement.Domain.Model.Commands; +using PERUSTARS.CommunicationAndNotificationManagement.Domain.Services; +using System.Threading; +using System.Threading.Tasks; + +namespace PERUSTARS.AtEventManagement.Application.artevents.events +{ + public class ArtEventRescheduledEventHandler : INotificationHandler + { + private readonly INotificationCommandService _notificationCommandService; + public ArtEventRescheduledEventHandler(INotificationCommandService notificationCommandService) + { + _notificationCommandService = notificationCommandService; + } + public async Task Handle(ArtEventRescheduledEvent notification, CancellationToken cancellationToken) + { + NotifyArtEventRescheduledCommand notifyArtEventRescheduledCommand = new NotifyArtEventRescheduledCommand(); + notifyArtEventRescheduledCommand.Title = notification.Title; + notifyArtEventRescheduledCommand.Description = notification.Description; + notifyArtEventRescheduledCommand.Location = notification.Location; + notifyArtEventRescheduledCommand.StartDate = notification.StartDate; + notifyArtEventRescheduledCommand.CurrentStatus = notification.CurrentStatus; + await _notificationCommandService.ExecuteNotifyArtEventRescheduledCommand(notifyArtEventRescheduledCommand); + } + } +} diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/events/CancelledArtEventEventHandler.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/events/CancelledArtEventEventHandler.cs new file mode 100644 index 0000000..b85eff7 --- /dev/null +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Application/artevents/events/CancelledArtEventEventHandler.cs @@ -0,0 +1,33 @@ +using MediatR; +using PERUSTARS.AtEventManagement.Domain.Model.domainevents; +using PERUSTARS.CommunicationAndNotificationManagement.Domain.Model.Commands; +using PERUSTARS.CommunicationAndNotificationManagement.Domain.Services; +using PERUSTARS.Shared.Domain.Repositories; +using System.Threading; +using System.Threading.Tasks; + +namespace PERUSTARS.AtEventManagement.Application.artevents.events +{ + public class CancelledArtEventEventHandler : INotificationHandler + { + private readonly IUnitOfWork _unitOfWork; + private readonly INotificationCommandService _notificationCommandService; + public CancelledArtEventEventHandler(INotificationCommandService notificationCommandService, IUnitOfWork unitOfWork) + { + _notificationCommandService = notificationCommandService; + _unitOfWork = unitOfWork; + } + + public async Task Handle(ArtEventCancelledEvent notification, CancellationToken cancellationToken) + { + NotifyArtEventCancelledCommand notifyArtEventCancelledCommand = new NotifyArtEventCancelledCommand(); + notifyArtEventCancelledCommand.Title = notification.Title; + notifyArtEventCancelledCommand.Description= notification.Description; + notifyArtEventCancelledCommand.Location = notification.Location; + notifyArtEventCancelledCommand.EndDate = notification.EndDate; + notifyArtEventCancelledCommand.CurrentStatus = notification.CurrentStatus; + notifyArtEventCancelledCommand.StartDate = notification.StartDate; + await _notificationCommandService.ExecuteNotifyArtEventCancelledCommand(notifyArtEventCancelledCommand); + } + } +} diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Domain/Model/domainevents/ArtEventCancelledEvent.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Domain/Model/domainevents/ArtEventCancelledEvent.cs new file mode 100644 index 0000000..7e94f35 --- /dev/null +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Domain/Model/domainevents/ArtEventCancelledEvent.cs @@ -0,0 +1,16 @@ +using MediatR; +using PERUSTARS.AtEventManagement.Domain.Model.ValueObjects; +using System; + +namespace PERUSTARS.AtEventManagement.Domain.Model.domainevents +{ + public class ArtEventCancelledEvent:INotification + { + public string Title { set; get; } + public string Description { set; get; } + public Location Location { set; get; } + public DateTime StartDate { get; set; } //ArtEventStartDate + public DateTime EndDate { get; set; } //ArtEventEndDate + public ArtEventStatus CurrentStatus { get; set; } + } +} diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Domain/Model/domainevents/ArtEventRescheduledEvent.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Domain/Model/domainevents/ArtEventRescheduledEvent.cs new file mode 100644 index 0000000..79328e4 --- /dev/null +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Domain/Model/domainevents/ArtEventRescheduledEvent.cs @@ -0,0 +1,15 @@ +using MediatR; +using PERUSTARS.AtEventManagement.Domain.Model.ValueObjects; +using System; + +namespace PERUSTARS.AtEventManagement.Domain.Model.domainevents +{ + public class ArtEventRescheduledEvent:INotification + { + public string Title { get; set; } //ArtEventTitle + public string Description { get; set; } //ArtEventDescription + public Location Location { get; set; } //ArtEventLocation + public DateTime StartDate { get; set; } //ArtEventStartDate + public ArtEventStatus CurrentStatus { get; set; } //ArtEventStatus + } +} diff --git a/PERUSTARS/PERUSTARS/AtEventManagement/Interfaces/rest/ArtEventController.cs b/PERUSTARS/PERUSTARS/AtEventManagement/Interfaces/rest/ArtEventController.cs index 1868d5f..1fb9e61 100644 --- a/PERUSTARS/PERUSTARS/AtEventManagement/Interfaces/rest/ArtEventController.cs +++ b/PERUSTARS/PERUSTARS/AtEventManagement/Interfaces/rest/ArtEventController.cs @@ -47,6 +47,15 @@ public async Task cancelArtEvent(int id) { string response = await _artEventCommandService.cancelArtEvent(cancelArtEventCommand); return Ok(response); } + [HttpPost("start/{id}")] + public async Task startArtEvent(int id) { + StartArtEventCommand startArtEventCommand = new StartArtEventCommand(); + startArtEventCommand.id= id; + string response= await _artEventCommandService.startArtEventCommand(startArtEventCommand); + return Ok(response); + + } + [HttpPut("edit")] public async Task editArtEvent([FromBody] EditArtEventCommand editArtEventCommand) { diff --git a/PERUSTARS/PERUSTARS/appsettings.json b/PERUSTARS/PERUSTARS/appsettings.json index b845262..9b04d44 100644 --- a/PERUSTARS/PERUSTARS/appsettings.json +++ b/PERUSTARS/PERUSTARS/appsettings.json @@ -11,6 +11,7 @@ }, "ConnectionStrings": { + //"DefaultConnection1ssssss": "server=localhost;port=3306;database=perustars;uid=root;password=admin", // BD Deployment //"DefaultConnection": "server=perustars-main-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Admin123" //"DefaultConnection3": "Server=MYSQL5047.site4now.net;Database=db_a758df_perusta;Uid=a758df_perusta;Pwd=password1",