Academatica.Api/Academatica.Api.Users/Controllers/UsersController.cs
/// <summary>
/// Endpoint used by admin to delete a user.
/// </summary>
/// <param name="id">User ID.</param>
Endpoint used by admin to delete a user.
Endpoint used by admin to delete a user .
[Authorize(Roles = "Admin")]
        [HttpDelete]
        [Route("{id}")]
        public async Task<IActionResult> DeleteUser(Guid id)
        {
            var user = _academaticaDbContext.Users.Where(x => x.Id == id).FirstOrDefault();
            if (user == null)
            {
                return BadRequest("Invalid user ID.");
            }
            _academaticaDbContext.Users.Remove(user);
            await _academaticaDbContext.SaveChangesAsync();
            return Ok($"User {id} deleted");
        }
[ Authorize ( Roles = " " ) ] [ HttpDelete ] [ Route ( " " ) ] public async Task < IActionResult > DeleteUser ( Guid id ) { var user = _academaticaDbContext . Users . Where ( x => x . Id == id ) . FirstOrDefault ( ) ; if ( user == null ) { return BadRequest ( " " ) ; } _academaticaDbContext . Users . Remove ( user ) ; await _academaticaDbContext . SaveChangesAsync ( ) ; return Ok ( $" User  { id }  deleted " ) ; }
Endpoint used by admin to delete a user.
Endpoint used by admin to delete a user .
id
Guid
None