Skip to content

Commit de4a907

Browse files
committed
Created Endpoint for updating the admin, currently only changing the name is implemented and all that is needed
1 parent 83e2731 commit de4a907

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ClubService.API/Controller/AdminController.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ namespace ClubService.API.Controller;
99
[Route("api/v{version:apiVersion}/admins")]
1010
[ApiController]
1111
[ApiVersion("1.0")]
12-
public class AdminController(IRegisterAdminService registerAdminService, IDeleteAdminService deleteAdminService)
12+
public class AdminController(
13+
IRegisterAdminService registerAdminService,
14+
IDeleteAdminService deleteAdminService,
15+
IUpdateAdminService updateAdminService)
1316
: ControllerBase
1417
{
1518
[HttpPost]
@@ -34,4 +37,19 @@ public async Task<ActionResult<string>> DeleteAdmin(string id)
3437
var deletedAdminId = await deleteAdminService.DeleteAdmin(id);
3538
return Ok(deletedAdminId);
3639
}
40+
41+
[HttpPatch("{id}")]
42+
[ProducesResponseType(StatusCodes.Status200OK)]
43+
[ProducesResponseType(StatusCodes.Status404NotFound)]
44+
[ProducesResponseType(StatusCodes.Status400BadRequest)]
45+
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
46+
public async Task<ActionResult<string>> UpdateAdmin(string id, [FromBody] AdminUpdateCommand adminUpdateCommand)
47+
{
48+
var updatedAdminId = await updateAdminService.ChangeFullName(
49+
id,
50+
adminUpdateCommand.FirstName,
51+
adminUpdateCommand.LastName
52+
);
53+
return Ok(updatedAdminId);
54+
}
3755
}

0 commit comments

Comments
 (0)