Skip to content

Commit

Permalink
New - Ajout d'une vérification pour ne pas pouvoir supprimer un catal…
Browse files Browse the repository at this point in the history
…ogue consommateur
  • Loading branch information
noelmugnier committed Jun 10, 2021
1 parent d382945 commit 5687118
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sheaft.Core/Enums/MessageKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
12 changes: 12 additions & 0 deletions Sheaft.Localization/Resources/MessageResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Sheaft.Localization/Resources/MessageResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -933,4 +933,10 @@
<data name="Unauthenticated" xml:space="preserve">
<value>Vous devez être connecté pour accéder à cette ressource</value>
</data>
<data name="Catalogs" xml:space="preserve">
<value>Catalogue</value>
</data>
<data name="Catalogs_CannotRemove_Consumers" xml:space="preserve">
<value>Impossible de supprimer un catalogue consommateur, vous pouvez néanmoins le désactiver.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Sheaft.Mediatr/Catalog/Commands/DeleteCatalogCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public async Task<Result> 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);
Expand Down

0 comments on commit 5687118

Please sign in to comment.