Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 0a6d22b7

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Added endpoint to set global required annotations

Zobrazit rozdíly:

Backend/Backend/Controllers/DocumentController.cs
99 99

  
100 100
        return Ok();
101 101
    }
102

  
103
    [HttpPost("/documents/requiredAnnotations/global")]
104
    [Authorize(Models.Enums.ERole.ADMINISTRATOR)]
105
    [ProducesResponseType((int)HttpStatusCode.OK)]
106
    [ProducesResponseType((int)HttpStatusCode.Forbidden)]
107
    public ActionResult SetRequiredAnnotationsGlobal([FromServices] ClientInfo clientInfo, [FromBody] SetRequiredAnnotationsGlobalRequest request)
108
    {
109
        if (clientInfo.LoggedUser == null)
110
        {
111
            logger.Warning("ClientInfo has null LoggerUser in [Authorized] controller /documents");
112
            return Problem();
113
        }
114

  
115
        try
116
        {
117
            documentService.SetRequiredAnnotationsGlobal(request.RequiredAnnotations);
118
        }
119
        catch (InvalidOperationException e)
120
        {
121
            throw new BadRequestException(e.Message);
122
        }
123
        catch (Exception e)
124
        {
125
            throw new InternalErrorException(e.Message);
126
        }
127

  
128
        return Ok();
129
    }
102 130
}
103 131

  
Backend/Core/Services/DocumentService/DocumentServiceEF.cs
164 164
            }
165 165
            databaseContext.SaveChanges();
166 166
        }
167

  
168
        public void SetRequiredAnnotationsGlobal(int requiredAnnotations)
169
        {
170
            GlobalConfiguration.RequiredAnnotations = requiredAnnotations;
171
        }
172

  
167 173
    }
168 174
}
Backend/Core/Services/DocumentService/IDocumentService.cs
16 16
        public DocumentListResponse GetDocuments(int pageIdnex, int pageSize);
17 17

  
18 18
        public void SetRequiredAnnotationsForDocuments(SetRequiredAnnotationsRequest request);
19

  
20
        public void SetRequiredAnnotationsGlobal(int requiredAnnotations);
19 21
    }
20 22
}
Backend/Models/Documents/SetRequiredAnnotationsGlobalRequest.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace Models.Documents
8
{
9
    public class SetRequiredAnnotationsGlobalRequest
10
    {
11
        public int RequiredAnnotations { get; set; }
12
    }
13
}

Také k dispozici: Unified diff