コード例 #1
0
        public async Task <IActionResult> Post(int id, [FromBody] Stream value)
        {
            var currentUser = HttpContext.User.Identity.Name;

            //Posting a New document after posting the metadata
            var meta = _metadataRepository.GetById(id, true, false);

            if (meta == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentCreate, "Document", id.ToString()));
            }

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Create, meta.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentCreate, "Document", id.ToString()));
            }

            await _documentRepository.SetDocumentAsync(meta, value);

            _logger.Log(LogLevel.Debug, "Uploaded New Document {0} for User {1}", meta.Id, HttpContext.User.Identity.Name);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentCreate, id, "Document", true);

            return(Ok());
        }
コード例 #2
0
        public IActionResult ListByBuisnessArea(string buisnessArea, [FromQuery] int page = 0, [FromQuery] int perPage = 25, [FromQuery] bool getAll = false)
        {
            string currentUser = HttpContext.User.Identity.Name;

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Return, buisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentMetadataSearch, "Metadata", buisnessArea));
            }

            int pageCount;
            List <MetadataEntity> metaItems = _metadataRepository.ListByBuisnessArea(buisnessArea, page, perPage, out pageCount, getAll: getAll);

            if (metaItems.Count == 0)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentMetadataSearch, "Metadata", buisnessArea));
            }

            _logger.Log(LogLevel.Information, "Getting DocumentMetadata Within BuisnessArea {0} for User {1}", buisnessArea, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentMetadataSearch, buisnessArea, "Metadata", true);

            HttpContext.Response.Headers.Add(new KeyValuePair <string, StringValues>("TotalPages", pageCount.ToString()));

            return(Ok(metaItems));
        }