99using IdentityManager2 . Resources ;
1010using Microsoft . AspNetCore . Authorization ;
1111using Microsoft . AspNetCore . Mvc ;
12- using Microsoft . AspNetCore . Mvc . Infrastructure ;
13- using Microsoft . AspNetCore . Mvc . Routing ;
1412using static System . String ;
1513
1614namespace IdentityManager2 . Api . Controllers
@@ -21,15 +19,11 @@ namespace IdentityManager2.Api.Controllers
2119 public class UsersController : Controller
2220 {
2321 private readonly IIdentityManagerService service ;
24- private readonly IUrlHelperFactory urlHelperFactory ;
25- private readonly IActionContextAccessor actionContextAccessor ;
2622 private IdentityManagerMetadata metadata ;
2723
28- public UsersController ( IIdentityManagerService service , IUrlHelperFactory urlHelperFactory , IActionContextAccessor actionContextAccessor )
24+ public UsersController ( IIdentityManagerService service )
2925 {
3026 this . service = service ?? throw new ArgumentNullException ( nameof ( service ) ) ;
31- this . urlHelperFactory = urlHelperFactory ?? throw new ArgumentNullException ( nameof ( urlHelperFactory ) ) ;
32- this . actionContextAccessor = actionContextAccessor ?? throw new ArgumentNullException ( nameof ( actionContextAccessor ) ) ;
3327 }
3428
3529 public async Task < IdentityManagerMetadata > GetMetadataAsync ( )
@@ -52,9 +46,7 @@ public async Task<IActionResult> GetUsersAsync(string filter = null, int start =
5246 {
5347 var meta = await GetMetadataAsync ( ) ;
5448
55- var resource = new UserQueryResultResource ( result . Result ,
56- urlHelperFactory . GetUrlHelper ( actionContextAccessor . ActionContext ) ,
57- meta . UserMetadata ) ;
49+ var resource = new UserQueryResultResource ( result . Result , Url , meta . UserMetadata ) ;
5850 return Ok ( resource ) ;
5951 }
6052
@@ -82,13 +74,11 @@ public async Task<IActionResult> CreateUserAsync([FromBody] PropertyValue[] prop
8274 var result = await service . CreateUserAsync ( properties ) ;
8375 if ( result . IsSuccess )
8476 {
85- var urlHelper = urlHelperFactory . GetUrlHelper ( actionContextAccessor . ActionContext ) ;
86-
87- var url = urlHelper . Link ( IdentityManagerConstants . RouteNames . GetUser , new { subject = result . Result . Subject } ) ;
77+ var url = Url . Link ( IdentityManagerConstants . RouteNames . GetUser , new { subject = result . Result . Subject } ) ;
8878 var resource = new
8979 {
90- Data = new { subject = result . Result . Subject } ,
91- Links = new { detail = url }
80+ Data = new { subject = result . Result . Subject } ,
81+ Links = new { detail = url }
9282 } ;
9383
9484 return Created ( url , resource ) ;
0 commit comments