Remove await Task.FromResult() and unnecessary async modifiers (#16535)

* Remove await Task.FromResult and unnecessary async modifiers

* Remove usage of await Task.WhenAll() to avoid deadlocks

* Fix code formatting

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
Ronald Barendse
2025-03-03 06:47:37 +01:00
committed by GitHub
parent 064a71240e
commit 561d871677
126 changed files with 600 additions and 574 deletions

View File

@@ -18,9 +18,9 @@ public class DeleteByKeyRedirectUrlManagementController : RedirectUrlManagementC
[MapToApiVersion("1.0")]
[HttpDelete("{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteByKey(CancellationToken cancellationToken, Guid id)
public Task<IActionResult> DeleteByKey(CancellationToken cancellationToken, Guid id)
{
_redirectUrlService.Delete(id);
return Ok();
return Task.FromResult<IActionResult>(Ok());
}
}

View File

@@ -27,7 +27,7 @@ public class GetAllRedirectUrlManagementController : RedirectUrlManagementContro
[HttpGet]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(PagedViewModel<RedirectUrlResponseModel>), StatusCodes.Status200OK)]
public async Task<ActionResult<PagedViewModel<RedirectUrlResponseModel>>> GetAll(
public Task<ActionResult<PagedViewModel<RedirectUrlResponseModel>>> GetAll(
CancellationToken cancellationToken,
string? filter,
int skip = 0,
@@ -39,6 +39,6 @@ public class GetAllRedirectUrlManagementController : RedirectUrlManagementContro
: _redirectUrlService.SearchRedirectUrls(filter, skip, take, out total);
IEnumerable<RedirectUrlResponseModel> redirectViewModels = _redirectUrlPresentationFactory.CreateMany(redirects);
return new PagedViewModel<RedirectUrlResponseModel> { Items = redirectViewModels, Total = total };
return Task.FromResult<ActionResult<PagedViewModel<RedirectUrlResponseModel>>>(new PagedViewModel<RedirectUrlResponseModel> { Items = redirectViewModels, Total = total });
}
}