diff --git a/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterArtEventCommandHandler.cs b/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterArtEventCommandHandler.cs index 6735d62..045ccf7 100644 --- a/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterArtEventCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterArtEventCommandHandler.cs @@ -5,6 +5,8 @@ using PERUSTARS.ArtEventManagement.Domain.Model.Commads; using PERUSTARS.ArtEventManagement.Domain.Model.Repositories; using PERUSTARS.ArtEventManagement.Domain.Model.ValueObjects; +using PERUSTARS.ProfileManagement.Domain.Model.Aggregates; +using PERUSTARS.ProfileManagement.Domain.Repositories; using PERUSTARS.Shared.Domain.Repositories; namespace PERUSTARS.ArtEventManagement.Application.ArtEvents.Commands @@ -13,30 +15,32 @@ public class RegisterArtEventCommandHandler : IRequestHandler Handle(RegisterArtEventCommand request, CancellationToken cancellationToken) { //Primero se debe validar si existe el artista con el Id dado - + Artist artist=await _artistRepository.GetArtistByIdAsync(request.ArtistId); //"return No existe el Artista con el Id dado" //----------------------------------- + if(artist==null) { + return "This artist doesn't exist!!"; + } + var artEvent = new ArtEvent( - id: 0, title: request.Title, description: request.Description, startDateTime: request.StartDateTime, Location: request.Location, isOnline: request.IsOnline, artistId: request.ArtistId, - currentStatus: ArtEventStatus.REGISTERED, - Participants:null, - Artist:null, - collected:false + Artist:artist ); await _artEventRepository.AddAsync(artEvent); await _unitOfWork.CompleteAsync(); diff --git a/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterParticipantToArtEventCommandHandler.cs b/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterParticipantToArtEventCommandHandler.cs index 0ac57bd..8b01182 100644 --- a/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterParticipantToArtEventCommandHandler.cs +++ b/PERUSTARS/PERUSTARS/ArtEventManagement/Application/ArtEvents/Commands/RegisterParticipantToArtEventCommandHandler.cs @@ -30,8 +30,8 @@ public RegisterParticipantToArtEventCommandHandler(IParticipantRepository partic } public async Task Handle(RegisterParticipantToArtEventCommand request, CancellationToken cancellationToken) { - ArtEvent artEvent = _artEventRepository.FindByIdAsync(request.artEventId).Result; - Hobbyist hobbyist = _hobbyistRepository.FindByIdAsync(request.hobbyistId).Result; + ArtEvent artEvent = await _artEventRepository.FindByIdAsync(request.artEventId); + Hobbyist hobbyist = await _hobbyistRepository.FindByIdAsync(request.hobbyistId); Domain.Model.Aggregates.Participant participant = new Domain.Model.Aggregates.Participant( id: 0, userName: "A", diff --git a/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/ArtEvent.cs b/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/ArtEvent.cs index aa52eaa..c102e00 100644 --- a/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/ArtEvent.cs +++ b/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/ArtEvent.cs @@ -8,7 +8,7 @@ namespace PERUSTARS.ArtEventManagement.Domain.Model.Aggregates public class ArtEvent { - public long? Id { get; set; } + public long Id { get; set; } public string Title { get; set; } public string Description { get; set; } public DateTime? StartDateTime { get; set; } @@ -18,10 +18,26 @@ public class ArtEvent public Artist Artist { get; set; } public ArtEventStatus? CurrentStatus { get; set; } public IEnumerable Participants { get; set; } - public bool Collected { get; set; } + public bool Collected { get; set; }=false; public ArtEvent() { } - public ArtEvent(long? id, + public ArtEvent(string title, + string description, + DateTime? startDateTime, + Location Location, bool? isOnline, + long? artistId, + Artist Artist) { + Title = title; + Description = description; + StartDateTime = startDateTime; + this.Location = Location; + IsOnline = isOnline; + ArtistId = artistId; + this.Artist = Artist; + this.CurrentStatus = ArtEventStatus.REGISTERED; + this.Participants= new List(); + } + public ArtEvent(long id, string title, string description, DateTime? startDateTime, diff --git a/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/Participant.cs b/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/Participant.cs index b794584..85fcf50 100644 --- a/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/Participant.cs +++ b/PERUSTARS/PERUSTARS/ArtEventManagement/Domain/Model/Aggregates/Participant.cs @@ -28,7 +28,7 @@ public Participant(long id, string userName, DateTime registerDateTime, DateTime ArtEventId = artEventId; Hobyst = hobbyist; ArtEvent = artEvent; - Collected = collected; + Collected = false; } } } diff --git a/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ArtEventsController.cs b/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ArtEventsController.cs index 095e79f..f3df852 100644 --- a/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ArtEventsController.cs +++ b/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ArtEventsController.cs @@ -72,7 +72,7 @@ public async Task getByArtist(int id) { IEnumerable events= _artEventQueryService.getArtEventByArtistId(id); return Ok(events); } - [HttpPost("art-events/{id}/participant")] + [HttpPost("art-events/participant")] public async Task createParticipant([FromBody] RegisterParticipantToArtEventCommand registerParticipantToArtEvent) { string response= await _artEventCommandService.registerParticipantToArtEvent(registerParticipantToArtEvent); return Ok(response); diff --git a/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ParticipantsController.cs b/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ParticipantsController.cs index 9030667..794a3c9 100644 --- a/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ParticipantsController.cs +++ b/PERUSTARS/PERUSTARS/ArtEventManagement/Interfaces/REST/ParticipantsController.cs @@ -24,7 +24,7 @@ public ParticipantsController(IMapper mapper, IParticipantQueryService participa _participantCommandService=participantCommandService; } - [HttpGet] + [HttpGet("participants")] public async Task getParticipants() { IEnumerable participants = _participantQueryService.GetParticipants();