ソースを参照

Merge branch 'feature/1831_refactoring' of Neca/HRCenter into BE_dev

pull/138/head
safet.purkovic 3年前
コミット
d85443c621

+ 2
- 2
Diligent.WebAPI.Business/Services/Interfaces/IUserService.cs ファイルの表示

@@ -5,8 +5,8 @@ namespace Diligent.WebAPI.Business.Services.Interfaces
public interface IUserService
{
Task<IEnumerable<User?>> GetAll();
Task<User?> GetById(int id);
Task<User?> GetByEmail(string email);
Task<User> GetById(int id);
Task<User> GetByEmail(string email);
Task CreateUser(CreateUserRequestDto model);
Task<bool?> ToggleEnable(User user);
Task RemoveUser(User user);

+ 19
- 3
Diligent.WebAPI.Business/Services/UserService.cs ファイルの表示

@@ -36,14 +36,30 @@
return result;
}
#region REFACTORING CODE HERE TO CHECK IF USER IS NULL
public async Task<User?> GetById(int id)
public async Task<User> GetById(int id)
{
_logger.LogInformation($"Start searching user with id = {id}");
var result = await _userManager.FindByIdAsync(id.ToString());

if (result == null)
{
throw new EntityNotFoundException("User not found");
}

return result;
}
public async Task<User> GetByEmail(string email)
{
_logger.LogInformation($"Start searching user with mail = {email}");
var result = await _userManager.FindByEmailAsync(email);

if (result == null)
{
throw new EntityNotFoundException("User not found");
}

return result;
}
public async Task<User?> GetByEmail(string email) =>
await _userManager.FindByEmailAsync(email);
#endregion
public async Task CreateUser(CreateUserRequestDto model)
{

+ 0
- 15
Diligent.WebAPI.Host/Controllers/V1/UsersController.cs ファイルの表示

@@ -30,11 +30,6 @@ namespace Diligent.WebAPI.Host.Controllers.V1
{
var user = await _userService.GetById(id);

if (user == null)
{
return BadRequest("User not found");
}

await _userService.ToggleEnable(user);

return Ok(user.Id);
@@ -46,11 +41,6 @@ namespace Diligent.WebAPI.Host.Controllers.V1
{
var user = await _userService.GetById(id);

if (user == null)
{
return BadRequest("User not found");
}

await _userService.RemoveUser(user);

return Ok(user.Id);
@@ -62,11 +52,6 @@ namespace Diligent.WebAPI.Host.Controllers.V1
{
var user = await _userService.GetById(id);

if (user == null)
{
return BadRequest("User not found");
}

return Ok(_mapper.Map<User, UserDetailsResponseDTO>(user));
}


読み込み中…
キャンセル
保存