1
1
using CheckDrive . Application . Constants ;
2
- using CheckDrive . Application . DTOs . Account ;
2
+ using CheckDrive . Application . DTOs . Employee ;
3
3
using CheckDrive . Application . Interfaces ;
4
- using CheckDrive . Domain . Enums ;
4
+ using CheckDrive . Application . QueryParameters ;
5
5
using Microsoft . AspNetCore . Authorization ;
6
6
using Microsoft . AspNetCore . Mvc ;
7
7
8
8
namespace CheckDrive . Api . Controllers ;
9
9
10
- [ Route ( "api/accounts " ) ]
10
+ [ Route ( "api/employees " ) ]
11
11
[ ApiController ]
12
- public class AccountsController : ControllerBase
12
+ public class EmployeesController : ControllerBase
13
13
{
14
- private readonly IAccountService _service ;
14
+ private readonly IEmployeeService _service ;
15
15
16
- public AccountsController ( IAccountService service )
16
+ public EmployeesController ( IEmployeeService service )
17
17
{
18
18
_service = service ?? throw new ArgumentNullException ( nameof ( service ) ) ;
19
19
}
20
20
21
21
[ HttpGet ]
22
- public async Task < ActionResult < List < AccountDto > > > GetAsync ( EmployeePosition ? position )
22
+ public async Task < ActionResult < List < EmployeeDto > > > GetAsync ( [ FromQuery ] EmployeeQueryParameters queryParameters )
23
23
{
24
- var accounts = await _service . GetAsync ( position ) ;
24
+ var accounts = await _service . GetAsync ( queryParameters ) ;
25
25
26
26
return Ok ( accounts ) ;
27
27
}
28
28
29
- [ HttpGet ( "{id}" , Name = nameof ( GetAccountByIdAsync ) ) ]
30
- public async Task < ActionResult < AccountDto > > GetAccountByIdAsync ( string id )
29
+ [ HttpGet ( "{id}" , Name = nameof ( GetEmployeeByIdAsync ) ) ]
30
+ public async Task < ActionResult < EmployeeDto > > GetEmployeeByIdAsync ( string id )
31
31
{
32
32
var account = await _service . GetByIdAsync ( id ) ;
33
33
@@ -36,15 +36,15 @@ public async Task<ActionResult<AccountDto>> GetAccountByIdAsync(string id)
36
36
37
37
[ HttpPost ]
38
38
[ Authorize ( Roles = $ "{ Roles . Manager } ,{ Roles . Administrator } ") ]
39
- public async Task < ActionResult < AccountDto > > CreateAsync ( [ FromBody ] CreateAccountDto account )
39
+ public async Task < ActionResult < EmployeeDto > > CreateAsync ( [ FromBody ] CreateEmployeeDto account )
40
40
{
41
41
var createdAccount = await _service . CreateAsync ( account ) ;
42
42
43
- return CreatedAtAction ( nameof ( GetAccountByIdAsync ) , new { id = createdAccount . Id } , createdAccount ) ;
43
+ return CreatedAtAction ( nameof ( GetEmployeeByIdAsync ) , new { id = createdAccount . Id } , createdAccount ) ;
44
44
}
45
45
46
46
[ HttpPut ( "{id}" ) ]
47
- public async Task < ActionResult < AccountDto > > UpdateAsync ( [ FromRoute ] string id , [ FromBody ] UpdateAccountDto account )
47
+ public async Task < ActionResult < EmployeeDto > > UpdateAsync ( [ FromRoute ] string id , [ FromBody ] UpdateEmployeeDto account )
48
48
{
49
49
if ( id != account . Id )
50
50
{
0 commit comments