Exemplo n.º 1
0
 public static async Task RemoveCancelledLibraryItems(IDatabaseComponent database)
 {
     using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
     {
         await database.ExecuteAsync(database.Queries.RemoveCancelledLibraryItems).ConfigureAwait(false);
     }
 }
Exemplo n.º 2
0
 public static Task RemovePlaylistItems(IDatabaseComponent database, int playlistId, PlaylistItemStatus status, ITransactionSource transaction)
 {
     return(database.ExecuteAsync(database.Queries.RemovePlaylistItems, (parameters, phase) =>
     {
         switch (phase)
         {
         case DatabaseParameterPhase.Fetch:
             parameters["playlistId"] = playlistId;
             parameters["status"] = status;
             break;
         }
     }, transaction));
 }
Exemplo n.º 3
0
        public static Task UpdatePlaylistItem(IDatabaseComponent database, PlaylistItem playlistItem, ITransactionSource transaction)
        {
            var table   = database.Tables.PlaylistItem;
            var builder = database.QueryFactory.Build();

            builder.Update.SetTable(table);
            builder.Update.AddColumns(table.UpdatableColumns);
            builder.Filter.AddColumns(table.PrimaryKeys);
            var query      = builder.Build();
            var parameters = new ParameterHandlerStrategy(table, playlistItem).Handler;

            return(database.ExecuteAsync(query, parameters, transaction));
        }
Exemplo n.º 4
0
 public static Task RemoveHierarchies(IDatabaseComponent database, LibraryHierarchy libraryHierarchy, LibraryItemStatus?status, ITransactionSource transaction)
 {
     return(database.ExecuteAsync(database.Queries.RemoveLibraryHierarchyItems, (parameters, phase) =>
     {
         switch (phase)
         {
         case DatabaseParameterPhase.Fetch:
             if (libraryHierarchy != null)
             {
                 parameters["libraryHierarchyId"] = libraryHierarchy.Id;
             }
             if (status.HasValue)
             {
                 parameters["status"] = status;
             }
             break;
         }
     }, transaction));
 }
Exemplo n.º 5
0
        public static async Task SetLibraryItemsStatus(IDatabaseComponent database, LibraryItemStatus status)
        {
            var query = database.QueryFactory.Build();

            query.Update.SetTable(database.Tables.LibraryItem);
            query.Update.AddColumn(database.Tables.LibraryItem.Column("Status"));
            using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
            {
                await database.ExecuteAsync(query, (parameters, phase) =>
                {
                    switch (phase)
                    {
                    case DatabaseParameterPhase.Fetch:
                        parameters["status"] = status;
                        break;
                    }
                }, transaction).ConfigureAwait(false);

                transaction.Commit();
            }
        }