/// <summary> /// 删除用户 /// </summary> /// <param name="id">将删除的用户的ID</param> /// <returns>状态码,<see cref="StatusCodes.Status204NoContent"/>代表删除成功,<see cref="StatusCodes.Status404NotFound"/>代表未找到</returns> public async Task <int> DeleteUserAsync(int id) { // 获取用户 UserData data = await dataContext.FindAsync <UserData>(id); if (data == null) { return(StatusCodes.Status404NotFound); } do { // 在Auth0上删除 await userClient.DeleteAsync(data.StringUserID); } while (null != await userClient.GetAsync(data.StringUserID)); // 在本地数据库中删除 dataContext.Remove <UserData>(data); dataContext.SaveChanges(); return(StatusCodes.Status204NoContent); }