public async Task <ListResponseModel <EventResponseModel> > GetCipher(string id, [FromQuery] DateTime?start = null, [FromQuery] DateTime?end = null, [FromQuery] string continuationToken = null) { var cipher = await _cipherRepository.GetByIdAsync(new Guid(id)); if (cipher == null) { throw new NotFoundException(); } var canView = false; if (cipher.OrganizationId.HasValue) { canView = await _currentContext.AccessEventLogs(cipher.OrganizationId.Value); } else if (cipher.UserId.HasValue) { var userId = _userService.GetProperUserId(User).Value; canView = userId == cipher.UserId.Value; } if (!canView) { throw new NotFoundException(); } var dateRange = GetDateRange(start, end); var result = await _eventRepository.GetManyByCipherAsync(cipher, dateRange.Item1, dateRange.Item2, new PageOptions { ContinuationToken = continuationToken }); var responses = result.Data.Select(e => new EventResponseModel(e)); return(new ListResponseModel <EventResponseModel>(responses, result.ContinuationToken)); }