Add Identity configuration, DTOs and Mappers #1

Merged
m.bengashier merged 6 commits from Feat/Identity into main 2025-02-09 08:19:35 +00:00
2 changed files with 20 additions and 0 deletions
Showing only changes of commit 272ef7194e - Show all commits

View File

@@ -76,4 +76,15 @@ public class UserController : ControllerBase
var users = await _usersServices.GetAllUsersAsync();
return Ok(users);
}
[HttpDelete("Delete-User")]
public async Task<IActionResult> DeleteUser(string id)
{
var users = await _usersServices.GetUserByIdAsync(id);
if (users == null)
return NotFound();
var result = await _usersServices.DeleteUsersAsync(id);
return Ok(result);
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using survey_beta.DTOs.Create;
using survey_beta.DTOs.Default;
@@ -140,4 +141,12 @@ public class UsersServices
return userDtos;
}
public async Task<bool> DeleteUsersAsync(string userid)
{
var user = await _userManager.FindByIdAsync(userid);
if (user == null) return false;
var result = await _userManager.DeleteAsync(user);
if (!result.Succeeded) return false;
return true;
}
}