File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ using Microsoft . AspNetCore . Mvc ;
2
+ using WebhookRelayService . Services ;
3
+
4
+ namespace WebhookRelayService . Controllers
5
+ {
6
+ [ Route ( "api/[controller]" ) ]
7
+ public class HealthCheckController : ControllerBase
8
+ {
9
+ private IWebhookUserService _webhookUserService ;
10
+
11
+ public HealthCheckController ( IWebhookUserService webhookUserService )
12
+ {
13
+ _webhookUserService = webhookUserService ;
14
+ }
15
+
16
+ [ HttpGet ]
17
+ public async Task < int > HealthCheck ( )
18
+ {
19
+ return await _webhookUserService . GetRegisteredUsersCount ( ) ;
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public interface IWebhookUserRepository
10
10
public Task < WebhookUser > GetById ( Guid id ) ;
11
11
public Task < WebhookUser ? > GetByWebhookId ( int id ) ;
12
12
public Task Delete ( WebhookUser webhookUser ) ;
13
+ public Task < int > Count ( ) ;
13
14
}
14
15
15
16
public class WebhookUserRepository : IWebhookUserRepository
@@ -50,5 +51,10 @@ public async Task Delete(WebhookUser webhookUser)
50
51
_context . WebhookUsers . Remove ( webhookUser ) ;
51
52
await _context . SaveChangesAsync ( ) ;
52
53
}
54
+
55
+ public async Task < int > Count ( )
56
+ {
57
+ return await _context . WebhookUsers . CountAsync ( ) ;
58
+ }
53
59
}
54
60
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ public interface IWebhookUserService
8
8
{
9
9
public Task < Guid > Create ( WebhookUserCreateDTO dto ) ;
10
10
public Task Delete ( Guid id ) ;
11
+ public Task < int > GetRegisteredUsersCount ( ) ;
11
12
}
12
13
13
14
public class WebhookUserService : IWebhookUserService
@@ -43,6 +44,11 @@ public async Task Delete(Guid id)
43
44
await _repository . Delete ( user ) ;
44
45
}
45
46
47
+ public async Task < int > GetRegisteredUsersCount ( )
48
+ {
49
+ return await _repository . Count ( ) ;
50
+ }
51
+
46
52
private async Task < bool > CheckEndpoint ( string endpoint )
47
53
{
48
54
var httpResponse = await _httpService . SendGet ( endpoint ) ;
You can’t perform that action at this time.
0 commit comments