diff --git a/API_SQLuedo/API/Controllers/UsersController.cs b/API_SQLuedo/API/Controllers/UsersController.cs index 6a4b462..623360e 100644 --- a/API_SQLuedo/API/Controllers/UsersController.cs +++ b/API_SQLuedo/API/Controllers/UsersController.cs @@ -74,7 +74,7 @@ namespace API.Controllers if(success) { _logger.LogInformation("[INFORMATION] L'utilisateur avec l'id {id} a été supprimé.", id); - return Ok(_dataService.UserService.DeleteUser(id)); + return Ok(_dataService.UserService.DeleteItem(id)); } else { _logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); diff --git a/API_SQLuedo/ModelToEntity/DbDataManager.cs b/API_SQLuedo/ModelToEntity/DbDataManager.cs index c56dcf4..c4640e0 100644 --- a/API_SQLuedo/ModelToEntity/DbDataManager.cs +++ b/API_SQLuedo/ModelToEntity/DbDataManager.cs @@ -12,7 +12,7 @@ using System.Runtime.InteropServices.ObjectiveC; namespace ModelToEntity { - public class DbDataManager : IUserDataService + public class DbDataManager : IUserDataService { public async Task GetUserById(int id) { diff --git a/API_SQLuedo/ModelToEntity/Extension.cs b/API_SQLuedo/ModelToEntity/Extension.cs index 508e872..02c8edd 100644 --- a/API_SQLuedo/ModelToEntity/Extension.cs +++ b/API_SQLuedo/ModelToEntity/Extension.cs @@ -29,23 +29,23 @@ namespace ModelToEntity return Task.FromResult(item); } - internal static async Task DeleteItemAsync(this DbContext context, int? id) where T : class + internal static Task DeleteItemAsync(this DbContext context, int? id) where T : class { if (id == null) { - return false; + return Task.FromResult(false); } - var entity = await context.Set().FindAsync(id); + var entity = context.Set().Find(id); if (entity == null) { - return false; + return Task.FromResult(false); } context.Set().Remove(entity); - await context.SaveChangesAsync(); + context.SaveChanges(); - return true; + return Task.FromResult(true); } internal static Task UpdateItemAsync(this DbContext context, int? id, TDto dto) where T : class diff --git a/API_SQLuedo/Shared/IUserDataService.cs b/API_SQLuedo/Shared/IUserDataService.cs index bf2f2e2..c6c646f 100644 --- a/API_SQLuedo/Shared/IUserDataService.cs +++ b/API_SQLuedo/Shared/IUserDataService.cs @@ -10,7 +10,7 @@ using Model.Business; namespace Services { - public interface IUserDataService : IGenericService where T : class + public interface IUserDataService : IGenericService where T : class { public Task> GetUsers(int page, int number); public Task GetUserById(int id);