From 568711813d04bf658a6579ed9eba9dd3e207252f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Mugnier?= Date: Thu, 10 Jun 2021 22:48:49 +0200 Subject: [PATCH] =?UTF-8?q?New=20-=20Ajout=20d'une=20v=C3=A9rification=20p?= =?UTF-8?q?our=20ne=20pas=20pouvoir=20supprimer=20un=20catalogue=20consomm?= =?UTF-8?q?ateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sheaft.Core/Enums/MessageKind.cs | 2 ++ .../Resources/MessageResources.Designer.cs | 12 ++++++++++++ Sheaft.Localization/Resources/MessageResources.resx | 6 ++++++ .../Catalog/Commands/DeleteCatalogCommand.cs | 3 +++ 4 files changed, 23 insertions(+) diff --git a/Sheaft.Core/Enums/MessageKind.cs b/Sheaft.Core/Enums/MessageKind.cs index 934e1fc27..6ca981a6c 100644 --- a/Sheaft.Core/Enums/MessageKind.cs +++ b/Sheaft.Core/Enums/MessageKind.cs @@ -288,5 +288,7 @@ public enum MessageKind Withholding_Cannot_Process_Pending = 106101, Withholding_Cannot_Process_Already_Succeeded = 106102, Withholding_Cannot_Process_Payout_No_Withholdings = 106103, + Catalogs = 107000, + Catalogs_CannotRemove_Consumers } } diff --git a/Sheaft.Localization/Resources/MessageResources.Designer.cs b/Sheaft.Localization/Resources/MessageResources.Designer.cs index 23c8a7d87..adb4db778 100644 --- a/Sheaft.Localization/Resources/MessageResources.Designer.cs +++ b/Sheaft.Localization/Resources/MessageResources.Designer.cs @@ -1676,5 +1676,17 @@ internal static string Unauthenticated { return ResourceManager.GetString("Unauthenticated", resourceCulture); } } + + internal static string Catalogs { + get { + return ResourceManager.GetString("Catalogs", resourceCulture); + } + } + + internal static string Catalogs_CannotRemove_Consumers { + get { + return ResourceManager.GetString("Catalogs_CannotRemove_Consumers", resourceCulture); + } + } } } diff --git a/Sheaft.Localization/Resources/MessageResources.resx b/Sheaft.Localization/Resources/MessageResources.resx index 550fb6767..893678e30 100644 --- a/Sheaft.Localization/Resources/MessageResources.resx +++ b/Sheaft.Localization/Resources/MessageResources.resx @@ -933,4 +933,10 @@ Vous devez être connecté pour accéder à cette ressource + + Catalogue + + + Impossible de supprimer un catalogue consommateur, vous pouvez néanmoins le désactiver. + \ No newline at end of file diff --git a/Sheaft.Mediatr/Catalog/Commands/DeleteCatalogCommand.cs b/Sheaft.Mediatr/Catalog/Commands/DeleteCatalogCommand.cs index 20b70ce92..55c5b744e 100644 --- a/Sheaft.Mediatr/Catalog/Commands/DeleteCatalogCommand.cs +++ b/Sheaft.Mediatr/Catalog/Commands/DeleteCatalogCommand.cs @@ -46,6 +46,9 @@ public async Task Handle(DeleteCatalogCommand request, CancellationToken await _context.Catalogs .SingleOrDefaultAsync(c => c.Id == request.CatalogId, token); + if (entity.Kind == CatalogKind.Consumers) + return Failure(MessageKind.Catalogs_CannotRemove_Consumers); + var agreements = await _context.Agreements .Where(a => a.Catalog != null && a.CatalogId == entity.Id) .ToListAsync(token);