Skip to content

Commit

Permalink
fix: partially fixed endpoint routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriprado committed Nov 14, 2023
1 parent 7f018f6 commit cc244a2
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using PERUSTARS.ArtEventManagement.Domain.Model.Queries;
using PERUSTARS.ArtEventManagement.Domain.Model.Repositories;
using PERUSTARS.ArtEventManagement.Interfaces.REST.Resources;
using PERUSTARS.ProfileManagement.Domain.Repositories;

namespace PERUSTARS.ArtEventManagement.Application.ArtEvents.Queries;

public class GetArtEventsByHobbyistQueryHandler: IRequestHandler<GetArtEventsByHobbyistQuery, IEnumerable<ArtEventResource>>
{
private readonly IArtEventRepository _artEventRepository;
private readonly IParticipantRepository _participantRepository;
private readonly IHobbyistRepository _hobbyistRepository;

public Task<IEnumerable<ArtEventResource>> Handle(GetArtEventsByHobbyistQuery request, CancellationToken cancellationToken)
{
throw new System.NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ParticipantQueryService: IParticipantQueryService
private readonly IParticipantRepository _participantRepository;
public ParticipantQueryService(IParticipantRepository participantRepository)
{
this._participantRepository = participantRepository;
_participantRepository = participantRepository;
}

public IEnumerable<Domain.Model.Aggregates.Participant> getParticipantByEventId(long id)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using MediatR;
using PERUSTARS.ArtEventManagement.Interfaces.REST.Resources;

namespace PERUSTARS.ArtEventManagement.Domain.Model.Queries;

public class GetArtEventsByHobbyistQuery: IRequest<IEnumerable<ArtEventResource>>
{
public long HobbyistId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
using PERUSTARS.ArtEventManagement.Domain.Model.Commads;
using PERUSTARS.ArtEventManagement.Domain.Model.ValueObjects;
using PERUSTARS.ArtEventManagement.Domain.Services.ArtEvent;
using PERUSTARS.ArtEventManagement.Interfaces.Resources;
using PERUSTARS.ArtEventManagement.Interfaces.REST.Resources;
using PERUSTARS.IdentityAndAccountManagement.Domain.Model.Attributes;

namespace PERUSTARS.ArtEventManagement.Interfaces.REST
{
[ApiController]
[Authorize]
[Route("/api/v1/[controller]")]
[Route("/api/v1")]
public class ArtEventsController : ControllerBase
{
private readonly IMapper _mapper;
Expand All @@ -34,52 +34,51 @@ public async Task<IActionResult> RegisterArtEvent([FromBody] RegisterArtEventRes
return Ok(response);
}

[HttpGet("{id}")]
[HttpGet("artevents/{id}")]
public async Task<IActionResult> GetArtEvent(int id)
{
ArtEvent artEvent = _artEventQueryService.getArtEventById(id);
return Ok(artEvent);
}

[HttpPost("cancel/{id}")]
[HttpPatch("artevents/{id}/cancel")]
public async Task<IActionResult> cancelArtEvent(int id) {
CancelArtEventCommand cancelArtEventCommand = new CancelArtEventCommand();
cancelArtEventCommand.id= id;
string response = await _artEventCommandService.cancelArtEvent(cancelArtEventCommand);
return Ok(response);
}
[HttpPost("start/{id}")]
[HttpPatch("artevents/{id}/start")]
public async Task<IActionResult> startArtEvent(int id) {
StartArtEventCommand startArtEventCommand = new StartArtEventCommand();
startArtEventCommand.id= id;
string response= await _artEventCommandService.startArtEventCommand(startArtEventCommand);
return Ok(response);

}

[HttpPut]
public async Task<IActionResult> editArtEvent([FromBody] EditArtEventCommand editArtEventCommand)
[HttpPut("artevents/{id}")]
public async Task<IActionResult> editArtEvent([FromBody] UpdateArtEventResource updateArtEventResource)
{
var editArtEventCommand = _mapper.Map<UpdateArtEventResource, EditArtEventCommand>(updateArtEventResource);
string response= await _artEventCommandService.editArtEvent(editArtEventCommand);
return Ok(response);
}
[HttpGet]
[HttpGet("artevents")]
public async Task<IActionResult> getALlEvents(){
IEnumerable<ArtEvent> events= _artEventQueryService.getArtEvents();
return Ok(events);
}
[HttpGet("artist/{id}")]
[HttpGet("artists/{id}/artevents")]
public async Task<IActionResult> getByArtist(int id) {
IEnumerable<ArtEvent> events= _artEventQueryService.getArtEventByArtistId(id);
return Ok(events);
}
[HttpPost("participant")]
[HttpPost("artevents/{id}/participant")]
public async Task<IActionResult> createParticipant([FromBody] RegisterParticipantToArtEventCommand registerParticipantToArtEvent) {
string response= await _artEventCommandService.registerParticipantToArtEvent(registerParticipantToArtEvent);
return Ok(response);
}

[HttpDelete("id")]
[HttpDelete("artevents/{id}")]
public async Task<IActionResult> deleteArtEvent(int id) {
DeleteArtEventCommand deleteArtEventCommand = new DeleteArtEventCommand();
deleteArtEventCommand.id=id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace PERUSTARS.ArtEventManagement.Interfaces.REST
{
[ApiController]
[Route("/api/v1/[controller]")]
[Route("/api/v1")]
[Authorize]
public class ParticipantsController : ControllerBase
{
Expand All @@ -31,20 +31,20 @@ public async Task<IActionResult> getParticipants()
return Ok(participants);
}

[HttpGet("hobbyist/{id}")]
[HttpGet("participants/hobbyist/{id}")]
public async Task<IActionResult> getParticipantsByHobbyistId(int id)
{
IEnumerable<Participant> participants = _participantQueryService.getParticipantByHobbyistId(id);
return Ok(participants);
}
[HttpGet("artevent/{id}")]
[HttpGet("participants/artevent/{id}")]
public async Task<IActionResult> getParticipantsByArtEventId(int id)
{
IEnumerable<Participant> participants = _participantQueryService.getParticipantByEventId(id);
return Ok(participants);
}

[HttpDelete("{id}")]
[HttpDelete("participants/{id}")]
public async Task<IActionResult> deleteParticipant(int id) {
DeleteParticipantCommand d = new DeleteParticipantCommand();
d.id = id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using PERUSTARS.ArtEventManagement.Domain.Model.Aggregates;
using PERUSTARS.ArtEventManagement.Domain.Model.ValueObjects;
using PERUSTARS.ProfileManagement.Domain.Model.Aggregates;

namespace PERUSTARS.ArtEventManagement.Interfaces.REST.Resources;

public class ArtEventResource
{
public long? Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime? StartDateTime { get; set; }
public Location Location { get; set; }
public bool? IsOnline { get; set; }
public long? ArtistId { get; set; }
public string? CurrentStatus { get; set; }
public IEnumerable<Participant> Participants { get; set; }
public bool Collected { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using PERUSTARS.ArtEventManagement.Domain.Model.ValueObjects;

namespace PERUSTARS.ArtEventManagement.Interfaces.Resources
namespace PERUSTARS.ArtEventManagement.Interfaces.REST.Resources
{
public class RegisterArtEventResource
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using PERUSTARS.ArtEventManagement.Domain.Model.ValueObjects;

namespace PERUSTARS.ArtEventManagement.Interfaces.REST.Resources;

public class UpdateArtEventResource
{
public int id { get; set; }
public string title { get; set; }
public string description { get; set; }
public Location location { get; set; }
public bool isOnline { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@
namespace PERUSTARS.CommunicationAndNotificationManagement.Interfaces.REST
{
[Authorize]
[Route("api/v1/[controller]")]
[Route("api/v1")]
[ApiController]
public class NotificationsController : ControllerBase
{
private readonly INotificationCommandService _notificationCommandService;
private readonly IMapper _mapper;

[HttpGet("artist/{artistId}")]
public NotificationsController(INotificationCommandService notificationCommandService, IMapper mapper)
{
_notificationCommandService = notificationCommandService;
_mapper = mapper;
}

[HttpGet("artists/{artistId}/notifications")]
public async Task<IActionResult> GetNotificationsByArtistId(long artistId)
{
var notifications = await _notificationCommandService.ListNotificationsReceivedBydArtistIdAsync(artistId);
Expand All @@ -30,10 +36,10 @@ public async Task<IActionResult> GetNotificationsByArtistId(long artistId)
return Ok(result);
}

[HttpGet("hobbyist/{hoobyistId}")]
public async Task<IActionResult> GetNotificationsByHobbyistId(long hoobyistId)
[HttpGet("hobbyists/{hobbyistId}/notifications")]
public async Task<IActionResult> GetNotificationsByHobbyistId(long hobbyistId)
{
var notifications = await _notificationCommandService.ListNotificationsReceivedByHobbyistIdAsync(hoobyistId);
var notifications = await _notificationCommandService.ListNotificationsReceivedByHobbyistIdAsync(hobbyistId);
var result = _mapper.Map<IEnumerable<NotificationResource>>(notifications);

return Ok(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PERUSTARS.CommunicationAndNotificationManagement.Domain.Services;
using PERUSTARS.CommunicationAndNotificationManagement.Interfaces.REST.Resources;
using PERUSTARS.IdentityAndAccountManagement.Domain.Model.Attributes;
using PERUSTARS.ProfileManagement.Application.Exceptions;
using PERUSTARS.ProfileManagement.Domain.Model.Aggregates;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using AutoMapper;
using PERUSTARS.ArtEventManagement.Domain.Model.Commads;
using PERUSTARS.ArtEventManagement.Interfaces.REST.Resources;
using PERUSTARS.ArtworkManagement.Domain.Model.Commands;
using PERUSTARS.ArtworkManagement.Interfaces.REST.Resources;
using PERUSTARS.CommunicationAndNotificationManagement.Domain.Model.Commands;
Expand Down Expand Up @@ -30,6 +32,7 @@ public ResourceToCommandProfile()
CreateMap<NotificationResource, NotifyArtEventFinishedCommand>();
CreateMap<NotificationResource, NotifyArtEventCancelledCommand>();
CreateMap<NotificationResource, NotifyArtEventRescheduledCommand>();
CreateMap<UpdateArtEventResource, EditArtEventCommand>();
}
}
}
4 changes: 2 additions & 2 deletions PERUSTARS/PERUSTARS/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public void ConfigureServices(IServiceCollection services)

services.AddDbContext<AppDbContext>(options =>
{
//options.UseNpgsql(Configuration.GetConnectionString("PostgresSQLConnection"));
options.UseMySQL(Configuration.GetConnectionString("DefaultConnection"));
options.UseNpgsql(Configuration.GetConnectionString("PostgresSQLConnection"));
//options.UseMySQL(Configuration.GetConnectionString("DefaultConnection"));
});

services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
Expand Down
4 changes: 2 additions & 2 deletions PERUSTARS/PERUSTARS/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@


//"DefaultConnection1ssssss": "server=localhost;port=3306;database=perustars;uid=root;password=admin",
"DefaultConnection": "server=perustars-main-db.mysql.database.azure.com;port=3306;database=perustars;uid=perustarsAdmin;password=Admin123"
//"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",
//"DefaultConnection": "Server=bufyroukqdunhwcivvpo-mysql.services.clever-cloud.com;Database=bufyroukqdunhwcivvpo;Uid=ubcldvvxbrtlhp2d;Pwd=FltJthiJHLXaKDmKT11O"
//"PostgresSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
"PostgresSQLConnection": "host=localhost;port=5432;username=postgres;password=12345;database=perustars"
//"DefaultConnection": "host=localhost;port=3306;username=root;password=password;database=perustars"
// "DefaultConnection": "server=localhost;port=3306;database=perustars;uid=root;password=root"
},
Expand Down
Binary file modified PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.dll
Binary file not shown.
Binary file modified PERUSTARS/PERUSTARS/bin/Debug/net5.0/PERUSTARS.pdb
Binary file not shown.

0 comments on commit cc244a2

Please sign in to comment.