Пример #1
0
        public async Task <CDNFileDefinition> DeleteFileDefinition(CDNFileDefinition definition)
        {
            await using var conn = await Open();

            return((await conn.QueryAsync <CDNFileDefinition>(
                        "DELETE FROM dbo.AuthoredFiles WHERE ServerAssignedUniqueID = @Uid",
                        new { Uid = definition.ServerAssignedUniqueId })).First());
        }
Пример #2
0
        public async Task Finalize(CDNFileDefinition definition)
        {
            await using var conn = await Open();

            await conn.ExecuteAsync("UPDATE AuthoredFiles SET LastTouched = GETUTCDATE(), Finalized = GETUTCDATE() WHERE ServerAssignedUniqueId = @Uid",
                                    new {
                Uid = definition.ServerAssignedUniqueId
            });
        }
Пример #3
0
        public async Task DeleteFileDefinition(CDNFileDefinition definition)
        {
            await using var conn = await Open();

            await conn.ExecuteAsync(
                "DELETE FROM dbo.AuthoredFiles WHERE ServerAssignedUniqueID = @Uid",
                new { Uid = definition.ServerAssignedUniqueId });

            return;
        }
Пример #4
0
        public async Task <CDNFileDefinition> CreateAuthoredFile(CDNFileDefinition definition, string login)
        {
            definition.Author = login;
            var uid = Guid.NewGuid().ToString();

            await using var conn = await Open();

            definition.ServerAssignedUniqueId = uid;
            await conn.ExecuteAsync("INSERT INTO dbo.AuthoredFiles (ServerAssignedUniqueId, LastTouched, CDNFileDefinition) VALUES (@Uid, GETUTCDATE(), @CdnFile)",
                                    new {
                Uid     = uid,
                CdnFile = definition
            });

            return(definition);
        }
Пример #5
0
        public async Task TouchAuthoredFile(CDNFileDefinition definition, DateTime?date = null)
        {
            await using var conn = await Open();

            if (date == null)
            {
                await conn.ExecuteAsync(
                    "UPDATE AuthoredFiles SET LastTouched = GETUTCDATE() WHERE ServerAssignedUniqueId = @Uid",
                    new { Uid = definition.ServerAssignedUniqueId });
            }
            else
            {
                await conn.ExecuteAsync(
                    "UPDATE AuthoredFiles SET LastTouched = @Date WHERE ServerAssignedUniqueId = @Uid",
                    new { Uid = definition.ServerAssignedUniqueId, Date = date });
            }
        }