Exemple #1
0
        public IActionResult Get([FromQuery] int page = 0, [FromQuery] int perPage = 25)
        {
            var currentUser = HttpContext.User.Identity.Name;

            if (!_securityRepository.UserIsAdmin(HttpContext))
            {
                return(_securityRepository.Gate(GateType.Unathorised, AccessLogAction.BAList, currentUser, _objectType, string.Empty));
            }

            int pageCount;
            var buisnessAreas = _buisnessAreaRepository.ListP(out pageCount, perPage, page);

            if (buisnessAreas.Count() == 0)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.BAList, _objectType, string.Empty));
            }

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

            _securityRepository.LogUserAction(currentUser, AccessLogAction.BAList, string.Empty, _objectType, true);



            _securityRepository.SaveChanges();

            return(Ok(buisnessAreas));
        }
Exemple #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));
        }
        public async Task <IActionResult> Get(int id)
        {
            var currentUser = HttpContext.User.Identity.Name;

            var meta = _metadataRepository.GetById(id);

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

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Return, meta.BuisnessArea))
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentRead, "Document", id.ToString()));
            }

            var doc = await _documentRepository.GetDocumentAsync(meta);

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

            return(Ok(doc));
        }