From 646aa0908a45cb592d1fd9018fe1ce250991e011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Mugnier?= Date: Tue, 8 Dec 2020 16:03:56 +0100 Subject: [PATCH] Fix - Correction de la gestion des documents sur manage --- Sheaft.Web.Manage/Controllers/DocumentsController.cs | 6 +++--- Sheaft.Web.Manage/Views/Documents/Edit.cshtml | 6 +++--- Sheaft.Web.Manage/Views/Legals/EditLegalBusiness.cshtml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sheaft.Web.Manage/Controllers/DocumentsController.cs b/Sheaft.Web.Manage/Controllers/DocumentsController.cs index 7274ecad7..e8a615c92 100644 --- a/Sheaft.Web.Manage/Controllers/DocumentsController.cs +++ b/Sheaft.Web.Manage/Controllers/DocumentsController.cs @@ -257,6 +257,9 @@ public async Task DeletePage(Guid documentId, Guid pageId, Cancel [ValidateAntiForgeryToken] public async Task Delete(Guid id, CancellationToken token) { + var entity = await _context.Legals + .SingleOrDefaultAsync(c => c.Documents.Any(d => d.Id == id), token); + var result = await _mediatr.Process(new DeleteDocumentCommand(await GetRequestUser(token)) { Id = id @@ -265,9 +268,6 @@ public async Task Delete(Guid id, CancellationToken token) if (!result.Success) throw result.Exception; - var entity = await _context.Legals - .SingleOrDefaultAsync(c => c.Documents.Any(d => d.Id == id), token); - if (entity.Kind != LegalKind.Natural) return RedirectToAction("EditLegalBusiness", "Legals", new { entity.Id }); diff --git a/Sheaft.Web.Manage/Views/Documents/Edit.cshtml b/Sheaft.Web.Manage/Views/Documents/Edit.cshtml index 9c1e90610..0eef3a005 100644 --- a/Sheaft.Web.Manage/Views/Documents/Edit.cshtml +++ b/Sheaft.Web.Manage/Views/Documents/Edit.cshtml @@ -27,7 +27,7 @@ } } - @if (Model.Status == DocumentStatus.Locked || Model.Status == DocumentStatus.Refused || Model.Status == DocumentStatus.OutOfDate) + @if (Model.Status == DocumentStatus.Locked) { @using (Html.BeginForm("Unlock", "Documents", new { id = Model.Id }, FormMethod.Post, true, new { @class = "form d-inline" })) { @@ -149,7 +149,7 @@ Size UploadedOn - @if (Model.Status != DocumentStatus.Locked && Model.Status != DocumentStatus.Validated && Model.Status != DocumentStatus.ValidationAsked) + @if (Model.Status == DocumentStatus.Created || Model.Status == DocumentStatus.UnLocked) { @@ -173,7 +173,7 @@ } - @if (Model.Status != DocumentStatus.Locked && Model.Status != DocumentStatus.Validated && Model.Status != DocumentStatus.ValidationAsked) + @if (Model.Status == DocumentStatus.Created || Model.Status == DocumentStatus.UnLocked) { @using (Html.BeginForm("DeletePage", "Documents", new { documentId = Model.Id, pageId = docPage.Id }, FormMethod.Post, true, new { @class = "form d-inline" })) { diff --git a/Sheaft.Web.Manage/Views/Legals/EditLegalBusiness.cshtml b/Sheaft.Web.Manage/Views/Legals/EditLegalBusiness.cshtml index 8c63e8469..e7b0095e1 100644 --- a/Sheaft.Web.Manage/Views/Legals/EditLegalBusiness.cshtml +++ b/Sheaft.Web.Manage/Views/Legals/EditLegalBusiness.cshtml @@ -223,7 +223,7 @@ } - @if (document.Status != DocumentStatus.ValidationAsked && document.Status != DocumentStatus.Validated) + @if (document.Status == DocumentStatus.Created || document.Status == DocumentStatus.Refused) { @using (Html.BeginForm("Delete", "Documents", new { id = document.Id }, FormMethod.Post, true, new { @class = "form d-inline" })) {