Skip to content

Commit

Permalink
Add organizer endpoint (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticFragilist authored Mar 25, 2024
1 parent 9195d3f commit 4e62dbe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using api.core.Data;
using api.core.data.entities;
using api.core.Data;
using api.core.Data.Exceptions;
using api.core.Data.requests;
using api.core.Data.Responses;
using api.core.Misc;
Expand All @@ -16,6 +18,19 @@ namespace api.core.controllers;
[Route("api/moderator/organizer")]
public class ModeratorUserController(IUserService userService, IAuthService authService, IEmailService emailService) : ControllerBase
{
[AllowAnonymous]
[HttpGet("{organizerId}")]
public IActionResult GetOrganizer(Guid organizerId)
{
var user = userService.GetUser(organizerId);
return user.Type == "Organizer" ?
Ok(new Response<UserResponseDTO>
{
Data = user
})
: throw new NotFoundException<Organizer>();
}

[HttpPost]
public async Task<IActionResult> CreateOrganizer([FromBody] UserCreateDTO organizer)
{
Expand All @@ -29,7 +44,7 @@ await emailService.SendEmailAsync(
"Votre compte Hello!",
new UserCreationModel
{
Title = "Création de votre compte Hello",
Title = "Création de votre compte Hello!",
Salutation = $"Bonjour {organizer.Organization},",
AccountCreatedText = "Votre compte Hello a été créé!",
TemporaryPasswordHeader = "Votre mot de passe temporaire est: ",
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/Services/UserServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void GetUser_ShouldReturnUserResponseDTO_WhenModeratorIsFoundById()
UpdatedAt = DateTime.UtcNow
};

_organizerRepositoryMock.Setup(repo => repo.Get(moderatorId)).Returns((Organizer)null); // Simulate no organizer found
_organizerRepositoryMock.Setup(repo => repo.Get(moderatorId)).Returns((Organizer?)null); // Simulate no organizer found
_moderatorRepositoryMock.Setup(repo => repo.Get(moderatorId)).Returns(moderator); // Simulate moderator found

// Act
Expand Down

0 comments on commit 4e62dbe

Please sign in to comment.