public async Task <Document> CheckOutDocument(int documentId, int loginId) { DocumentAccessHistory accessHistory = GetAccessDetails(documentId, documentId, loginId, AccessLog.CheckedOut); await _accessRepository.InsertDocumentAccessLog(accessHistory); return(await _repository.CheckOutDocument(documentId, loginId)); }
public async Task <Document> GetDocumentById(int documentId, int loginId) { DocumentAccessHistory accessHistory = GetAccessDetails(documentId, documentId, loginId, AccessLog.Downloaded); await _accessRepository.InsertDocumentAccessLog(accessHistory); return(await _repository.GetDocumentById(documentId, loginId)); }
public async Task AddDocument(Document document, byte[] file) { if (document == null) { throw new ArgumentNullException(nameof(document), "Document should not be null"); } await _repository.AddDocument(document, file); DocumentAccessHistory accessHistory = GetAccessDetails(document.DocumentId, document.DocumentId, document.CreatedBy, AccessLog.Created); await _accessRepository.InsertDocumentAccessLog(accessHistory); }
public async Task InsertDocumentAccessLog(DocumentAccessHistory documentAccessHistory) { // Throws null exception if company value is null if (documentAccessHistory == null) { throw new ArgumentNullException(nameof(documentAccessHistory), "Document Access History should not be null"); } // returns new company with DepartmentId await _repository.InsertDocumentAccessLog(documentAccessHistory); }
DocumentAccessHistory GetAccessDetails(int historyId, int documentId, int loginId, AccessLog action) { DocumentAccessHistory accessHistory = new DocumentAccessHistory(); accessHistory.HistoryId = historyId; // will be autoincreameted accessHistory.DocumentId = documentId; accessHistory.PerformedBy = loginId; accessHistory.PerformedOn = DateTime.Now; accessHistory.Action = ((AccessLog)action).ToString(); return(accessHistory); }
public async Task <Document> CheckInDocument(int documentId, string why, string what, bool isNewRevision, byte[] file, string fileName, string extension, int loginId) { var action = AccessLog.RevisionCreation; if (!isNewRevision) { action = AccessLog.VersionCreation; } DocumentAccessHistory accessHistory = GetAccessDetails(documentId, documentId, loginId, action); await _accessRepository.InsertDocumentAccessLog(accessHistory); return(await _repository.CheckInDocument(documentId, why, what, isNewRevision, file, fileName, extension, loginId)); }
public async Task InsertDocumentAccessLog(DocumentAccessHistory documentAccessHistory) { await _context.AccessHistory.InsertOneAsync(documentAccessHistory); }
public IActionResult InsertDocumentAccessLog([FromBody] DocumentAccessHistory documentAccesHistory) { return(Execute(() => Ok(_documentAccessHistoryService.InsertDocumentAccessLog(documentAccesHistory)))); }