From df428b92014b14664d3aa234048f52c7181bf1e9 Mon Sep 17 00:00:00 2001 From: csimonapastore Date: Fri, 28 Mar 2025 22:38:10 +0100 Subject: [PATCH] Fixing issues --- MainProject.Tests/Controllers/UserController_Tests.cs | 2 +- MainProject/Services/RoleService.cs | 8 +++----- MainProject/Services/UserService.cs | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/MainProject.Tests/Controllers/UserController_Tests.cs b/MainProject.Tests/Controllers/UserController_Tests.cs index 1e4c415..cc94f2b 100644 --- a/MainProject.Tests/Controllers/UserController_Tests.cs +++ b/MainProject.Tests/Controllers/UserController_Tests.cs @@ -43,7 +43,7 @@ public class UserController_Tests IConfiguration configuration = TestUtils.CreateConfiguration(); _userServiceMock = new Mock(); _roleServiceMock = new Mock(); - _userController = new UserController(configuration, _userServiceMock?.Object, _roleServiceMock.Object); + _userController = new UserController(configuration, _userServiceMock.Object, _roleServiceMock.Object); } [TestMethod] diff --git a/MainProject/Services/RoleService.cs b/MainProject/Services/RoleService.cs index 703a939..a52b174 100644 --- a/MainProject/Services/RoleService.cs +++ b/MainProject/Services/RoleService.cs @@ -20,7 +20,6 @@ public interface IRoleService public class RoleService : BaseService, IRoleService { - private readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); public RoleService( IHttpContextAccessor httpContextAccessor, IConfiguration configuration, @@ -104,10 +103,9 @@ public class RoleService : BaseService, IRoleService await transaction.CommitAsync(); role = tempRole; } - catch (Exception exception) + catch (Exception) { await transaction.RollbackAsync(); - Logger.Error(exception, $"[RoleService][CreateRoleAsync]"); throw; } @@ -132,10 +130,10 @@ public class RoleService : BaseService, IRoleService await _sqlServerContext.SaveChangesAsync(); await transaction.CommitAsync(); } - catch (Exception exception) + catch (Exception) { await transaction.RollbackAsync(); - Logger.Error(exception, $"[RoleService][UpdateRoleAsync]"); + throw; } return role; diff --git a/MainProject/Services/UserService.cs b/MainProject/Services/UserService.cs index f4be4e2..9fb6253 100644 --- a/MainProject/Services/UserService.cs +++ b/MainProject/Services/UserService.cs @@ -19,7 +19,6 @@ public interface IUserService public class UserService : BaseService, IUserService { - private readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); public UserService( IHttpContextAccessor httpContextAccessor, IConfiguration configuration, @@ -116,10 +115,9 @@ public class UserService : BaseService, IUserService await transaction.CommitAsync(); user = tempUser; } - catch (Exception exception) + catch (Exception) { await transaction.RollbackAsync(); - Logger.Error(exception, $"[UserService][CreateUserAsync]"); throw; }