public IActionResult GetById(int id, DateTimeOffset?timestamp = null)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var status = _entityIndex.Status(ResourceType.Tag, id) ?? ContentStatus.Published;

            if (!UserPermissions.IsAllowedToGet(User.Identity, status, _entityIndex.Owner(ResourceType.Tag, id)))
            {
                return(Forbid());
            }

            var tag = _db.Database.GetCollection <Tag>(ResourceType.Tag.Name)
                      .AsQueryable()
                      .FirstOrDefault(x => x.Id == id);

            if (tag == null)
            {
                return(NotFound());
            }

            if (timestamp != null && tag.Timestamp <= timestamp.Value)
            {
                return(StatusCode(304));
            }

            var tagResult = new TagResult(tag)
            {
                Timestamp = _referencesIndex.LastModificationCascading(ResourceType.Tag, id)
            };

            return(Ok(tagResult));
        }
        public IActionResult GetById(int id, DateTimeOffset?timestamp = null)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var status = _entityIndex.Status(ResourceType.Media, id) ?? ContentStatus.Published;

            if (!UserPermissions.IsAllowedToGet(User.Identity, status, _entityIndex.Owner(ResourceType.Media, id)))
            {
                return(Forbid());
            }

            var media = _db.Database.GetCollection <MediaElement>(ResourceType.Media.Name)
                        .AsQueryable()
                        .FirstOrDefault(x => x.Id == id);

            if (media == null)
            {
                return(NotFound());
            }

            // Media instance wasn`t modified after timestamp
            if (timestamp != null && media.Timestamp <= timestamp)
            {
                return(StatusCode(304));
            }

            var result = new MediaResult(media)
            {
                File      = GenerateFileUrl(media),
                Timestamp = _referencesIndex.LastModificationCascading(ResourceType.Media, id)
            };

            return(Ok(result));
        }