U4-6147 - cleanup persistence units of work (in progress)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
internal class LockedRepository<TRepository>
|
||||
where TRepository : IDisposable, IRepository
|
||||
{
|
||||
public LockedRepository(ITransaction transaction, IDatabaseUnitOfWork unitOfWork, TRepository repository)
|
||||
{
|
||||
Transaction = transaction;
|
||||
UnitOfWork = unitOfWork;
|
||||
Repository = repository;
|
||||
}
|
||||
|
||||
public ITransaction Transaction { get; private set; }
|
||||
public IDatabaseUnitOfWork UnitOfWork { get; private set; }
|
||||
public TRepository Repository { get; private set; }
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
UnitOfWork.Commit();
|
||||
Transaction.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
internal class LockingRepository<TRepository>
|
||||
where TRepository : IDisposable, IRepository
|
||||
{
|
||||
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
|
||||
private readonly Func<IDatabaseUnitOfWork, TRepository> _repositoryFactory;
|
||||
private readonly int[] _readLockIds, _writeLockIds;
|
||||
|
||||
public LockingRepository(IDatabaseUnitOfWorkProvider uowProvider, Func<IDatabaseUnitOfWork, TRepository> repositoryFactory,
|
||||
IEnumerable<int> readLockIds, IEnumerable<int> writeLockIds)
|
||||
{
|
||||
Mandate.ParameterNotNull(uowProvider, "uowProvider");
|
||||
Mandate.ParameterNotNull(repositoryFactory, "repositoryFactory");
|
||||
|
||||
_uowProvider = uowProvider;
|
||||
_repositoryFactory = repositoryFactory;
|
||||
_readLockIds = readLockIds == null ? new int[0] : readLockIds.ToArray();
|
||||
_writeLockIds = writeLockIds == null ? new int[0] : writeLockIds.ToArray();
|
||||
}
|
||||
|
||||
public void WithReadLocked(Action<LockedRepository<TRepository>> action, bool autoCommit = true)
|
||||
{
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var transaction = uow.Database.GetTransaction(IsolationLevel.RepeatableRead))
|
||||
{
|
||||
foreach (var lockId in _readLockIds)
|
||||
uow.Database.AcquireLockNodeReadLock(lockId);
|
||||
|
||||
using (var repository = _repositoryFactory(uow))
|
||||
{
|
||||
action(new LockedRepository<TRepository>(transaction, uow, repository));
|
||||
if (autoCommit == false) return;
|
||||
uow.Commit();
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TResult WithReadLocked<TResult>(Func<LockedRepository<TRepository>, TResult> func, bool autoCommit = true)
|
||||
{
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var transaction = uow.Database.GetTransaction(IsolationLevel.RepeatableRead))
|
||||
{
|
||||
foreach (var lockId in _readLockIds)
|
||||
uow.Database.AcquireLockNodeReadLock(lockId);
|
||||
|
||||
using (var repository = _repositoryFactory(uow))
|
||||
{
|
||||
var ret = func(new LockedRepository<TRepository>(transaction, uow, repository));
|
||||
if (autoCommit == false) return ret;
|
||||
uow.Commit();
|
||||
transaction.Complete();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WithWriteLocked(Action<LockedRepository<TRepository>> action, bool autoCommit = true)
|
||||
{
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var transaction = uow.Database.GetTransaction(IsolationLevel.RepeatableRead))
|
||||
{
|
||||
foreach (var lockId in _writeLockIds)
|
||||
uow.Database.AcquireLockNodeWriteLock(lockId);
|
||||
|
||||
using (var repository = _repositoryFactory(uow))
|
||||
{
|
||||
action(new LockedRepository<TRepository>(transaction, uow, repository));
|
||||
if (autoCommit == false) return;
|
||||
uow.Commit();
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TResult WithWriteLocked<TResult>(Func<LockedRepository<TRepository>, TResult> func, bool autoCommit = true)
|
||||
{
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
using (var transaction = uow.Database.GetTransaction(IsolationLevel.RepeatableRead))
|
||||
{
|
||||
foreach (var lockId in _writeLockIds)
|
||||
uow.Database.AcquireLockNodeReadLock(lockId);
|
||||
|
||||
using (var repository = _repositoryFactory(uow))
|
||||
{
|
||||
var ret = func(new LockedRepository<TRepository>(transaction, uow, repository));
|
||||
if (autoCommit == false) return ret;
|
||||
uow.Commit();
|
||||
transaction.Complete();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,12 +36,12 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
public virtual void AddFolder(string folderPath)
|
||||
{
|
||||
_work.RegisterAdded(new Folder(folderPath), this);
|
||||
_work.RegisterCreated(new Folder(folderPath), this);
|
||||
}
|
||||
|
||||
public virtual void DeleteFolder(string folderPath)
|
||||
{
|
||||
_work.RegisterRemoved(new Folder(folderPath), this);
|
||||
_work.RegisterDeleted(new Folder(folderPath), this);
|
||||
}
|
||||
|
||||
#region Implementation of IRepository<TId,TEntity>
|
||||
@@ -50,11 +50,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
if (FileSystem.FileExists(entity.OriginalPath) == false)
|
||||
{
|
||||
_work.RegisterAdded(entity, this);
|
||||
_work.RegisterCreated(entity, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_work.RegisterChanged(entity, this);
|
||||
_work.RegisterUpdated(entity, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
if (_work != null)
|
||||
{
|
||||
_work.RegisterRemoved(entity, this);
|
||||
_work.RegisterDeleted(entity, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,11 +112,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
if (entity.HasIdentity == false)
|
||||
{
|
||||
UnitOfWork.RegisterAdded(entity, this);
|
||||
UnitOfWork.RegisterCreated(entity, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnitOfWork.RegisterChanged(entity, this);
|
||||
UnitOfWork.RegisterUpdated(entity, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="entity"></param>
|
||||
public virtual void Delete(TEntity entity)
|
||||
{
|
||||
UnitOfWork?.RegisterRemoved(entity, this);
|
||||
UnitOfWork?.RegisterDeleted(entity, this);
|
||||
}
|
||||
|
||||
protected abstract TEntity PerformGet(TId id);
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum for the 3 types of transactions
|
||||
/// </summary>
|
||||
internal enum TransactionType
|
||||
{
|
||||
Insert,
|
||||
Update,
|
||||
Delete
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Unit of Work implementation for working with files
|
||||
/// Represents a persistence unit of work for working with files.
|
||||
/// </summary>
|
||||
internal class FileUnitOfWork : DisposableObject, IUnitOfWork
|
||||
/// <remarks>The FileUnitOfWork does *not* implement transactions, so although it needs to be flushed or
|
||||
/// completed for operations to be executed, they are executed immediately without any commit or roll back
|
||||
/// mechanism.</remarks>
|
||||
internal class FileUnitOfWork : UnitOfWorkBase
|
||||
{
|
||||
private readonly Queue<Operation> _operations = new Queue<Operation>();
|
||||
private readonly RepositoryFactory _factory;
|
||||
|
||||
/// <summary>
|
||||
@@ -28,118 +26,9 @@ namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
/// <typeparam name="TRepository">The type of the repository.</typeparam>
|
||||
/// <param name="name">The optional name of the repository.</param>
|
||||
/// <returns>The created repository for the unit of work.</returns>
|
||||
public TRepository CreateRepository<TRepository>(string name = null)
|
||||
where TRepository : IRepository
|
||||
public override TRepository CreateRepository<TRepository>(string name = null)
|
||||
{
|
||||
return _factory.CreateRepository<TRepository>(this, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an <see cref="IEntity" /> instance to be added through this <see cref="IUnitOfWork" />.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository participating in the transaction.</param>
|
||||
public void RegisterAdded(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = TransactionType.Insert
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an <see cref="IEntity" /> instance to be changed through this <see cref="IUnitOfWork" />.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository participating in the transaction.</param>
|
||||
public void RegisterChanged(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = TransactionType.Update
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an <see cref="IEntity" /> instance to be removed through this <see cref="IUnitOfWork" />.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository participating in the transaction.</param>
|
||||
public void RegisterRemoved(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = TransactionType.Delete
|
||||
});
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
//NOTE: I'm leaving this in here for reference, but this is useless, transaction scope + Files doesn't do anything,
|
||||
// the closest you can get is transactional NTFS, but that requires distributed transaction coordinator and some other libs/wrappers,
|
||||
// plus MS has not deprecated it anyways. To do transactional IO we'd have to write this ourselves using temporary files and then
|
||||
// on committing move them to their correct place.
|
||||
//using(var scope = new TransactionScope())
|
||||
//{
|
||||
// // Commit the transaction
|
||||
// scope.Complete();
|
||||
//}
|
||||
|
||||
while (_operations.Count > 0)
|
||||
{
|
||||
var operation = _operations.Dequeue();
|
||||
switch (operation.Type)
|
||||
{
|
||||
case TransactionType.Insert:
|
||||
operation.Repository.PersistNewItem(operation.Entity);
|
||||
break;
|
||||
case TransactionType.Delete:
|
||||
operation.Repository.PersistDeletedItem(operation.Entity);
|
||||
break;
|
||||
case TransactionType.Update:
|
||||
operation.Repository.PersistUpdatedItem(operation.Entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// clear everything
|
||||
// fixme - why? everything should have been dequeued?
|
||||
_operations.Clear();
|
||||
}
|
||||
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
_operations.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a snapshot of an entity and the repository reference it belongs to.
|
||||
/// </summary>
|
||||
private sealed class Operation
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the entity.
|
||||
/// </summary>
|
||||
/// <value>The entity.</value>
|
||||
public IEntity Entity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the repository.
|
||||
/// </summary>
|
||||
/// <value>The repository.</value>
|
||||
public IUnitOfWorkRepository Repository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of operation.
|
||||
/// </summary>
|
||||
/// <value>The type of operation.</value>
|
||||
public TransactionType Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a unit of work when working with a database object
|
||||
/// Represents a persistence unit of work for working with a database.
|
||||
/// </summary>
|
||||
public interface IDatabaseUnitOfWork : IUnitOfWork, IDisposable
|
||||
public interface IDatabaseUnitOfWork : IUnitOfWork
|
||||
{
|
||||
UmbracoDatabase Database { get; }
|
||||
|
||||
|
||||
@@ -5,14 +5,70 @@ using Umbraco.Core.Persistence.Repositories;
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a Unit Of Work
|
||||
/// Represents a persistence unit of work.
|
||||
/// </summary>
|
||||
public interface IUnitOfWork : IDisposable
|
||||
{
|
||||
void RegisterAdded(IEntity entity, IUnitOfWorkRepository repository);
|
||||
void RegisterChanged(IEntity entity, IUnitOfWorkRepository repository);
|
||||
void RegisterRemoved(IEntity entity, IUnitOfWorkRepository repository);
|
||||
void Commit();
|
||||
/// <summary>
|
||||
/// Registers an entity to be created as part of this unit of work.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository in charge of the entity.</param>
|
||||
void RegisterCreated(IEntity entity, IUnitOfWorkRepository repository);
|
||||
|
||||
/// <summary>
|
||||
/// Registers an entity to be updated as part of this unit of work.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository in charge of the entity.</param>
|
||||
void RegisterUpdated(IEntity entity, IUnitOfWorkRepository repository);
|
||||
|
||||
/// <summary>
|
||||
/// Registers an entity to be deleted as part of this unit of work.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository in charge of the entity.</param>
|
||||
void RegisterDeleted(IEntity entity, IUnitOfWorkRepository repository);
|
||||
|
||||
/// <summary>
|
||||
/// Begins the unit of work.
|
||||
/// </summary>
|
||||
/// <remarks>When a unit of work begins, a local transaction scope is created at database level.
|
||||
/// This is useful eg when reading entities before creating, updating or deleting, and the read
|
||||
/// needs to be part of the transaction. Flushing or completing the unit of work automatically
|
||||
/// begins the transaction (so no need to call Begin if not necessary).</remarks>
|
||||
void Begin();
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the unit of work.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>When a unit of work is flushed, all queued operations are executed. This is useful eg
|
||||
/// when a row needs to be created in the database, so that its auto-generated ID can be retrieved.
|
||||
/// Note that it does *not* complete the unit of work, however. Completing the unit of work
|
||||
/// automatically flushes the queue (so no need to call Flush if not necessary).</para>
|
||||
/// </remarks>
|
||||
void Flush();
|
||||
|
||||
/// <summary>
|
||||
/// Completes the unit of work.
|
||||
/// </summary>
|
||||
/// <remarks>When a unit of work is completed, a local transaction scope is created at database level,
|
||||
/// all queued operations are executed, and the scope is commited. If the unit of work is not completed
|
||||
/// before it is disposed, all queued operations are cleared and the scope is rolled back (and also
|
||||
/// higher level transactions if any).
|
||||
/// Whether this actually commits or rolls back the transaction depends on whether the transaction scope
|
||||
/// is part of a higher level transactions. The database transaction is committed or rolled back only
|
||||
/// when the upper level scope is disposed.
|
||||
/// </remarks>
|
||||
void Complete();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a repository.
|
||||
/// </summary>
|
||||
/// <typeparam name="TRepository">The type of the repository.</typeparam>
|
||||
/// <param name="name">The optional name of the repository.</param>
|
||||
/// <returns>The created repository for the unit of work.</returns>
|
||||
TRepository CreateRepository<TRepository>(string name = null) where TRepository : IRepository;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using LightInject;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Unit of Work implementation for NPoco.
|
||||
/// </summary>
|
||||
internal class NPocoUnitOfWork : DisposableObject, IDatabaseUnitOfWork
|
||||
{
|
||||
private readonly Queue<Operation> _operations = new Queue<Operation>();
|
||||
/// <summary>
|
||||
/// Implements IDatabaseUnitOfWork for NPoco.
|
||||
/// </summary>
|
||||
internal class NPocoUnitOfWork : UnitOfWorkBase, IDatabaseUnitOfWork
|
||||
{
|
||||
private readonly RepositoryFactory _factory;
|
||||
private ITransaction _transaction;
|
||||
|
||||
@@ -24,10 +19,10 @@ namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
/// <param name="factory">A repository factory.</param>
|
||||
/// <remarks>This should be used by the NPocoUnitOfWorkProvider exclusively.</remarks>
|
||||
internal NPocoUnitOfWork(UmbracoDatabase database, RepositoryFactory factory)
|
||||
{
|
||||
Database = database;
|
||||
{
|
||||
Database = database;
|
||||
_factory = factory;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unit of work underlying database.
|
||||
@@ -40,175 +35,64 @@ namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
/// <typeparam name="TRepository">The type of the repository.</typeparam>
|
||||
/// <param name="name">The optional name of the repository.</param>
|
||||
/// <returns>The created repository for the unit of work.</returns>
|
||||
public TRepository CreateRepository<TRepository>(string name = null)
|
||||
where TRepository : IRepository
|
||||
public override TRepository CreateRepository<TRepository>(string name = null)
|
||||
{
|
||||
return _factory.CreateRepository<TRepository>(this, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an <see cref="IEntity" /> instance to be added through this <see cref="IUnitOfWork" />.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository participating in the transaction.</param>
|
||||
public void RegisterAdded(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = TransactionType.Insert
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an <see cref="IEntity" /> instance to be changed through this <see cref="IUnitOfWork" />.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository participating in the transaction.</param>
|
||||
public void RegisterChanged(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = TransactionType.Update
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an <see cref="IEntity" /> instance to be removed through this <see cref="IUnitOfWork" />.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository participating in the transaction.</param>
|
||||
public void RegisterRemoved(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = TransactionType.Delete
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that we have a transaction.
|
||||
/// Ensures that we have a transaction.
|
||||
/// </summary>
|
||||
/// <remarks>Isolation level is determined by the database, see UmbracoDatabase.DefaultIsolationLevel. Should be
|
||||
/// at least IsolationLevel.RepeatablRead else the node locks will not work correctly.</remarks>
|
||||
public void EnsureTransaction()
|
||||
{
|
||||
if (_transaction == null)
|
||||
_transaction = Database.GetTransaction();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Commits all batched changes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Unlike a typical unit of work, this UOW will let you commit more than once since a new transaction is creaed per
|
||||
/// Commit() call instead of having one transaction per UOW.
|
||||
/// </remarks>
|
||||
public void Commit()
|
||||
{
|
||||
Commit(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Commits all batched changes.
|
||||
/// </summary>
|
||||
/// <param name="completing">A callback which is executed after the operations have been processed and
|
||||
/// before the transaction is completed.</param>
|
||||
internal void Commit(Action<UmbracoDatabase> completing)
|
||||
public override void Begin()
|
||||
{
|
||||
EnsureTransaction();
|
||||
base.Begin();
|
||||
|
||||
try
|
||||
{
|
||||
while (_operations.Count > 0)
|
||||
{
|
||||
var operation = _operations.Dequeue();
|
||||
switch (operation.Type)
|
||||
{
|
||||
case TransactionType.Insert:
|
||||
operation.Repository.PersistNewItem(operation.Entity);
|
||||
break;
|
||||
case TransactionType.Delete:
|
||||
operation.Repository.PersistDeletedItem(operation.Entity);
|
||||
break;
|
||||
case TransactionType.Update:
|
||||
operation.Repository.PersistUpdatedItem(operation.Entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// execute the callback if there is one
|
||||
completing?.Invoke(Database);
|
||||
_transaction.Complete();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_transaction.Dispose(); // will rollback if not completed
|
||||
_transaction = null;
|
||||
}
|
||||
|
||||
// clear everything
|
||||
// in case the Dequeue loop was aborted
|
||||
// fixme - but the, exception and this is never reached?
|
||||
_operations.Clear();
|
||||
if (_transaction == null)
|
||||
_transaction = Database.GetTransaction();
|
||||
}
|
||||
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
_operations.Clear();
|
||||
base.DisposeResources();
|
||||
|
||||
// no transaction, nothing to do
|
||||
if (_transaction == null) return;
|
||||
_transaction.Dispose();
|
||||
|
||||
// will either complete or abort NPoco transaction
|
||||
// which means going one level up in the transaction stack
|
||||
// and commit or rollback only if at top of stack
|
||||
if (Completed)
|
||||
_transaction.Complete(); // complete the transaction
|
||||
else
|
||||
_transaction.Dispose(); // abort the transaction
|
||||
|
||||
_transaction = null;
|
||||
}
|
||||
|
||||
public void ReadLockNodes(params int[] lockIds)
|
||||
{
|
||||
EnsureTransaction();
|
||||
public void ReadLockNodes(params int[] lockIds)
|
||||
{
|
||||
Begin(); // we need a transaction
|
||||
|
||||
if (Database.Transaction.IsolationLevel < IsolationLevel.RepeatableRead)
|
||||
throw new InvalidOperationException("A transaction with minimum RepeatableRead isolation level is required.");
|
||||
// *not* using a unique 'WHERE IN' query here because the *order* of lockIds is important to avoid deadlocks
|
||||
foreach (var lockId in lockIds)
|
||||
Database.ExecuteScalar<int>("SELECT sortOrder FROM umbracoNode WHERE id=@id",
|
||||
new { @id = lockId });
|
||||
}
|
||||
|
||||
public void WriteLockNodes(params int[] lockIds)
|
||||
{
|
||||
EnsureTransaction();
|
||||
{
|
||||
Begin(); // we need a transaction
|
||||
|
||||
if (Database.Transaction.IsolationLevel < IsolationLevel.RepeatableRead)
|
||||
throw new InvalidOperationException("A transaction with minimum RepeatableRead isolation level is required.");
|
||||
// *not* using a unique 'WHERE IN' query here because the *order* of lockIds is important to avoid deadlocks
|
||||
foreach (var lockId in lockIds)
|
||||
Database.Execute("UPDATE umbracoNode SET sortOrder = (CASE WHEN (sortOrder=1) THEN -1 ELSE 1 END) WHERE id=@id",
|
||||
new { @id = lockId });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a snapshot of an entity and the repository reference it belongs to.
|
||||
/// </summary>
|
||||
private sealed class Operation
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the entity.
|
||||
/// </summary>
|
||||
/// <value>The entity.</value>
|
||||
public IEntity Entity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the repository.
|
||||
/// </summary>
|
||||
/// <value>The repository.</value>
|
||||
public IUnitOfWorkRepository Repository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of operation.
|
||||
/// </summary>
|
||||
/// <value>The type of operation.</value>
|
||||
public TransactionType Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
{
|
||||
public abstract class UnitOfWorkBase : DisposableObject, IUnitOfWork
|
||||
{
|
||||
private readonly Queue<Operation> _operations = new Queue<Operation>();
|
||||
|
||||
// fixme eventually kill this
|
||||
public virtual T CreateRepository<T>(string name = null) where T:IRepository { throw new NotImplementedException(); }
|
||||
|
||||
/// <summary>
|
||||
/// Registers an entity to be added as part of this unit of work.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository in charge of the entity.</param>
|
||||
public void RegisterCreated(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
Completed = false;
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = OperationType.Insert
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an entity to be updated as part of this unit of work.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository in charge of the entity.</param>
|
||||
public void RegisterUpdated(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
Completed = false;
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = OperationType.Update
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an entity to be deleted as part of this unit of work.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity.</param>
|
||||
/// <param name="repository">The repository in charge of the entity.</param>
|
||||
public void RegisterDeleted(IEntity entity, IUnitOfWorkRepository repository)
|
||||
{
|
||||
Completed = false;
|
||||
_operations.Enqueue(new Operation
|
||||
{
|
||||
Entity = entity,
|
||||
Repository = repository,
|
||||
Type = OperationType.Delete
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void Begin()
|
||||
{ }
|
||||
|
||||
public virtual void Flush()
|
||||
{
|
||||
Begin();
|
||||
|
||||
while (_operations.Count > 0)
|
||||
{
|
||||
var operation = _operations.Dequeue();
|
||||
switch (operation.Type)
|
||||
{
|
||||
case OperationType.Insert:
|
||||
operation.Repository.PersistNewItem(operation.Entity);
|
||||
break;
|
||||
case OperationType.Delete:
|
||||
operation.Repository.PersistDeletedItem(operation.Entity);
|
||||
break;
|
||||
case OperationType.Update:
|
||||
operation.Repository.PersistUpdatedItem(operation.Entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Complete()
|
||||
{
|
||||
Flush();
|
||||
Completed = true;
|
||||
}
|
||||
|
||||
protected bool Completed { get; private set; }
|
||||
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
// whatever hasn't been commited is lost
|
||||
// not sure we need this as we are being disposed...
|
||||
_operations.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a snapshot of an entity and the repository reference it belongs to.
|
||||
/// </summary>
|
||||
private sealed class Operation
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the entity.
|
||||
/// </summary>
|
||||
/// <value>The entity.</value>
|
||||
public IEntity Entity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the repository.
|
||||
/// </summary>
|
||||
/// <value>The repository.</value>
|
||||
public IUnitOfWorkRepository Repository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of operation.
|
||||
/// </summary>
|
||||
/// <value>The type of operation.</value>
|
||||
public OperationType Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The types of unit of work operation.
|
||||
/// </summary>
|
||||
private enum OperationType
|
||||
{
|
||||
Insert,
|
||||
Update,
|
||||
Delete
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, comment, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Core.Services
|
||||
private readonly IUserService _userService;
|
||||
private readonly IEnumerable<IUrlSegmentProvider> _urlSegmentProviders;
|
||||
|
||||
//Support recursive locks because some of the methods that require locking call other methods that require locking.
|
||||
//Support recursive locks because some of the methods that require locking call other methods that require locking.
|
||||
//for example, the Move method needs to be locked but this calls the Save method which also needs to be locked.
|
||||
private static readonly ReaderWriterLockSlim Locker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
@@ -175,8 +175,8 @@ namespace Umbraco.Core.Services
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(content.Id, string.Format("Content '{0}' was created", name), AuditType.New, content.CreatorId));
|
||||
uow.Commit();
|
||||
repo.AddOrUpdate(new AuditItem(content.Id, $"Content '{name}' was created", AuditType.New, content.CreatorId));
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
return content;
|
||||
@@ -252,22 +252,20 @@ namespace Umbraco.Core.Services
|
||||
return content;
|
||||
}
|
||||
|
||||
content.CreatorId = userId;
|
||||
content.WriterId = userId;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
content.CreatorId = userId;
|
||||
content.WriterId = userId;
|
||||
repository.AddOrUpdate(content);
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IContent>(content, false), this);
|
||||
|
||||
Created.RaiseEvent(new NewEventArgs<IContent>(content, false, contentTypeAlias, parentId), this);
|
||||
|
||||
Audit(AuditType.New, string.Format("Content '{0}' was created with Id {1}", name, content.Id), content.CreatorId, content.Id);
|
||||
Audit(AuditType.New, $"Content '{name}' was created with Id {content.Id}", content.CreatorId, content.Id);
|
||||
|
||||
return content;
|
||||
}
|
||||
@@ -306,22 +304,20 @@ namespace Umbraco.Core.Services
|
||||
return content;
|
||||
}
|
||||
|
||||
content.CreatorId = userId;
|
||||
content.WriterId = userId;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
content.CreatorId = userId;
|
||||
content.WriterId = userId;
|
||||
repository.AddOrUpdate(content);
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IContent>(content, false), this);
|
||||
|
||||
Created.RaiseEvent(new NewEventArgs<IContent>(content, false, contentTypeAlias, parent), this);
|
||||
|
||||
Audit(AuditType.New, string.Format("Content '{0}' was created with Id {1}", name, content.Id), content.CreatorId, content.Id);
|
||||
Audit(AuditType.New, $"Content '{name}' was created with Id {content.Id}", content.CreatorId, content.Id);
|
||||
|
||||
return content;
|
||||
}
|
||||
@@ -557,7 +553,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="orderBy">Field to order by</param>
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy = "Path", Direction orderDirection = Direction.Ascending, string filter = "")
|
||||
{
|
||||
return GetPagedDescendants(id, pageIndex, pageSize, out totalChildren, orderBy, orderDirection, true, filter);
|
||||
@@ -574,7 +570,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="orderDirection">Direction to order by</param>
|
||||
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
|
||||
/// <param name="filter">Search text filter</param>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
|
||||
public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
|
||||
{
|
||||
Mandate.ParameterCondition(pageIndex >= 0, "pageIndex");
|
||||
@@ -830,12 +826,12 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will rebuild the xml structures for content in the database.
|
||||
/// This will rebuild the xml structures for content in the database.
|
||||
/// </summary>
|
||||
/// <param name="userId">This is not used for anything</param>
|
||||
/// <returns>True if publishing succeeded, otherwise False</returns>
|
||||
/// <remarks>
|
||||
/// This is used for when a document type alias or a document type property is changed, the xml will need to
|
||||
/// This is used for when a document type alias or a document type property is changed, the xml will need to
|
||||
/// be regenerated.
|
||||
/// </remarks>
|
||||
public bool RePublishAll(int userId = 0)
|
||||
@@ -853,7 +849,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will rebuild the xml structures for content in the database.
|
||||
/// This will rebuild the xml structures for content in the database.
|
||||
/// </summary>
|
||||
/// <param name="contentTypeIds">
|
||||
/// If specified will only rebuild the xml for the content type's specified, otherwise will update the structure
|
||||
@@ -949,28 +945,27 @@ namespace Umbraco.Core.Services
|
||||
UnPublish(descendant, userId);
|
||||
}
|
||||
|
||||
content.WriterId = userId;
|
||||
content.ChangeTrashedState(true);
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
content.WriterId = userId;
|
||||
content.ChangeTrashedState(true);
|
||||
repository.AddOrUpdate(content);
|
||||
|
||||
//Loop through descendants to update their trash state, but ensuring structure by keeping the ParentId
|
||||
foreach (var descendant in descendants)
|
||||
{
|
||||
moveInfo.Add(new MoveEventInfo<IContent>(descendant, descendant.Path, descendant.ParentId));
|
||||
|
||||
descendant.WriterId = userId;
|
||||
descendant.ChangeTrashedState(true, descendant.ParentId);
|
||||
repository.AddOrUpdate(descendant);
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Trashed.RaiseEvent(new MoveEventArgs<IContent>(false, evtMsgs, moveInfo.ToArray()), this);
|
||||
|
||||
Audit(AuditType.Move, "Move Content to Recycle Bin performed by user", userId, content.Id);
|
||||
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
@@ -1080,10 +1075,10 @@ namespace Umbraco.Core.Services
|
||||
|
||||
/// <summary>
|
||||
/// Saves a collection of <see cref="IContent"/> objects.
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
/// <param name="contents">Collection of <see cref="IContent"/> to save</param>
|
||||
/// <param name="userId">Optional Id of the User saving the Content</param>
|
||||
/// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
|
||||
/// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
|
||||
Attempt<OperationStatus> IContentServiceOperations.Save(IEnumerable<IContent> contents, int userId, bool raiseEvents)
|
||||
{
|
||||
var asArray = contents.ToArray();
|
||||
@@ -1132,12 +1127,11 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
Saved.RaiseEvent(new SaveEventArgs<IContent>(asArray, false, evtMsgs), this);
|
||||
|
||||
Audit(AuditType.Save, "Bulk Save content performed by user", userId == -1 ? 0 : userId, Constants.System.Root);
|
||||
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
@@ -1183,7 +1177,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
repository.Delete(content);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
var args = new DeleteEventArgs<IContent>(content, false, evtMsgs);
|
||||
Deleted.RaiseEvent(args, this);
|
||||
@@ -1243,10 +1237,10 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="userId">Optional Id of the user issueing the delete operation</param>
|
||||
public void DeleteContentOfType(int contentTypeId, int userId = 0)
|
||||
{
|
||||
//TODO: This currently this is called from the ContentTypeService but that needs to change,
|
||||
//TODO: This currently this is called from the ContentTypeService but that needs to change,
|
||||
// if we are deleting a content type, we should just delete the data and do this operation slightly differently.
|
||||
// This method will recursively go lookup every content item, check if any of it's descendants are
|
||||
// of a different type, move them to the recycle bin, then permanently delete the content items.
|
||||
// of a different type, move them to the recycle bin, then permanently delete the content items.
|
||||
// The main problem with this is that for every content item being deleted, events are raised...
|
||||
// which we need for many things like keeping caches in sync, but we can surely do this MUCH better.
|
||||
|
||||
@@ -1316,7 +1310,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
repository.DeleteVersions(id, versionDate);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedVersions.RaiseEvent(new DeleteRevisionsEventArgs(id, false, dateToRetain: versionDate), this);
|
||||
@@ -1349,7 +1343,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
repository.DeleteVersion(versionId);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedVersions.RaiseEvent(new DeleteRevisionsEventArgs(id, false, specificVersion: versionId), this);
|
||||
@@ -1448,7 +1442,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies an <see cref="IContent"/> object by creating a new Content object of the same type and copies all data from the current
|
||||
/// Copies an <see cref="IContent"/> object by creating a new Content object of the same type and copies all data from the current
|
||||
/// to the new copy which is returned. Recursively copies all children.
|
||||
/// </summary>
|
||||
/// <param name="content">The <see cref="IContent"/> to copy</param>
|
||||
@@ -1462,7 +1456,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies an <see cref="IContent"/> object by creating a new Content object of the same type and copies all data from the current
|
||||
/// Copies an <see cref="IContent"/> object by creating a new Content object of the same type and copies all data from the current
|
||||
/// to the new copy which is returned.
|
||||
/// </summary>
|
||||
/// <param name="content">The <see cref="IContent"/> to copy</param>
|
||||
@@ -1497,7 +1491,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdate(copy);
|
||||
//add or update a preview
|
||||
repository.AddOrUpdatePreviewXml(copy, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
uow.Commit();
|
||||
uow.Flush(); // ensure copy has an ID
|
||||
|
||||
|
||||
//Special case for the associated tags
|
||||
@@ -1512,6 +1506,8 @@ namespace Umbraco.Core.Services
|
||||
uow.Database.Insert(new TagRelationshipDto { NodeId = copy.Id, TagId = tag.TagId, PropertyTypeId = tag.PropertyTypeId });
|
||||
}
|
||||
}
|
||||
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (recursive)
|
||||
@@ -1574,21 +1570,19 @@ namespace Umbraco.Core.Services
|
||||
if (RollingBack.IsRaisedEventCancelled(new RollbackEventArgs<IContent>(content), this))
|
||||
return content;
|
||||
|
||||
content.WriterId = userId;
|
||||
content.CreatorId = userId;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
content.WriterId = userId;
|
||||
content.CreatorId = userId;
|
||||
content.ChangePublishedState(PublishedState.Unpublished);
|
||||
|
||||
repository.AddOrUpdate(content);
|
||||
//add or update a preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
RolledBack.RaiseEvent(new RollbackEventArgs<IContent>(content, false), this);
|
||||
|
||||
Audit(AuditType.RollBack, "Content rollback performed by user", content.WriterId, content.Id);
|
||||
|
||||
return content;
|
||||
@@ -1659,7 +1653,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdateContentXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1722,8 +1716,7 @@ namespace Umbraco.Core.Services
|
||||
repository.RebuildXmlStructures(
|
||||
content => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, content),
|
||||
contentTypeIds: contentTypeIds.Length == 0 ? null : contentTypeIds);
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Publish, "ContentService.RebuildXmlStructures completed, the xml has been regenerated in the database", 0, Constants.System.Root);
|
||||
@@ -1759,7 +1752,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1807,7 +1800,7 @@ namespace Umbraco.Core.Services
|
||||
//TODO: This is raising events, probably not desirable as this costs performance for event listeners like Examine
|
||||
Save(content, false, userId);
|
||||
|
||||
//TODO: This shouldn't be here! This needs to be part of the repository logic but in order to fix this we need to
|
||||
//TODO: This shouldn't be here! This needs to be part of the repository logic but in order to fix this we need to
|
||||
// change how this method calls "Save" as it needs to save using an internal method
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
@@ -1845,7 +1838,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="content">The <see cref="IContent"/> to publish along with its children</param>
|
||||
/// <param name="userId">Optional Id of the User issueing the publishing</param>
|
||||
/// <param name="includeUnpublished">If set to true, this will also publish descendants that are completely unpublished, normally this will only publish children that have previously been published</param>
|
||||
/// <param name="includeUnpublished">If set to true, this will also publish descendants that are completely unpublished, normally this will only publish children that have previously been published</param>
|
||||
/// <returns>
|
||||
/// A list of publish statues. If the parent document is not valid or cannot be published because it's parent(s) is not published
|
||||
/// then the list will only contain one status item, otherwise it will contain status items for it and all of it's descendants that
|
||||
@@ -1922,7 +1915,7 @@ namespace Umbraco.Core.Services
|
||||
updated.Add(item.Result.ContentItem);
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
}
|
||||
//Save xml to db and call following method to fire event:
|
||||
@@ -1959,17 +1952,17 @@ namespace Umbraco.Core.Services
|
||||
var unpublished = _publishingStrategy.UnPublish(content, userId);
|
||||
if (unpublished == false) return Attempt.Fail(new UnPublishStatus(content, UnPublishedStatusType.FailedCancelledByEvent, evtMsgs));
|
||||
|
||||
content.WriterId = userId;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
content.WriterId = userId;
|
||||
repository.AddOrUpdate(content);
|
||||
// is published is not newest, reset the published flag on published version
|
||||
if (published.Version != content.Version)
|
||||
repository.ClearPublished(published);
|
||||
repository.DeleteContentXml(content);
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
//Delete xml from db? and call following method to fire event through PublishingStrategy to update cache
|
||||
if (omitCacheRefresh == false)
|
||||
@@ -2054,7 +2047,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdateContentXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -2121,7 +2114,7 @@ namespace Umbraco.Core.Services
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, c));
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -2282,7 +2275,7 @@ namespace Umbraco.Core.Services
|
||||
#region Event Handlers
|
||||
/// <summary>
|
||||
/// Occurs before Delete
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IContentService, DeleteEventArgs<IContent>> Deleting;
|
||||
|
||||
/// <summary>
|
||||
@@ -2292,7 +2285,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Delete Versions
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IContentService, DeleteRevisionsEventArgs> DeletingVersions;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
repo.AddOrUpdate(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
SavedContentTypeContainer.RaiseEvent(new SaveEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
//TODO: Audit trail ?
|
||||
@@ -104,7 +104,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
repo.AddOrUpdate(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
SavedMediaTypeContainer.RaiseEvent(new SaveEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
//TODO: Audit trail ?
|
||||
@@ -164,7 +164,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateContainerRepository(containerObjectType);
|
||||
repo.AddOrUpdate(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
savedEvent.RaiseEvent(new SaveEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
@@ -297,7 +297,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
repo.Delete(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedContentTypeContainer.RaiseEvent(new DeleteEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
repo.Delete(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedMediaTypeContainer.RaiseEvent(new DeleteEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
|
||||
@@ -744,7 +744,7 @@ namespace Umbraco.Core.Services
|
||||
contentType.CreatorId = userId;
|
||||
repository.AddOrUpdate(contentType);
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
UpdateContentXmlStructure(contentType);
|
||||
@@ -782,7 +782,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
//save it all in one go
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
UpdateContentXmlStructure(asArray.Cast<IContentTypeBase>().ToArray());
|
||||
@@ -817,7 +817,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IContentTypeRepository>();
|
||||
repository.Delete(contentType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedContentType.RaiseEvent(new DeleteEventArgs<IContentType>(contentType, false), this);
|
||||
}
|
||||
@@ -856,7 +856,7 @@ namespace Umbraco.Core.Services
|
||||
repository.Delete(contentType);
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedContentType.RaiseEvent(new DeleteEventArgs<IContentType>(asArray, false), this);
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ namespace Umbraco.Core.Services
|
||||
return Attempt.Fail(
|
||||
new OperationStatus<MoveOperationStatusType>(ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
MovedMediaType.RaiseEvent(new MoveEventArgs<IMediaType>(false, evtMsgs, moveInfo.ToArray()), this);
|
||||
@@ -1082,7 +1082,7 @@ namespace Umbraco.Core.Services
|
||||
return Attempt.Fail(
|
||||
new OperationStatus<MoveOperationStatusType>(ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
MovedContentType.RaiseEvent(new MoveEventArgs<IContentType>(false, evtMsgs, moveInfo.ToArray()), this);
|
||||
@@ -1128,7 +1128,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
return Attempt.Fail(new OperationStatus<IMediaType, MoveOperationStatusType>(null, ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
return Attempt.Succeed(new OperationStatus<IMediaType, MoveOperationStatusType>(copy, MoveOperationStatusType.Success, evtMsgs));
|
||||
@@ -1171,7 +1171,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
return Attempt.Fail(new OperationStatus<IContentType, MoveOperationStatusType>(null, ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
return Attempt.Succeed(new OperationStatus<IContentType, MoveOperationStatusType>(copy, MoveOperationStatusType.Success, evtMsgs));
|
||||
@@ -1195,7 +1195,7 @@ namespace Umbraco.Core.Services
|
||||
ValidateLocked(mediaType); // throws if invalid
|
||||
mediaType.CreatorId = userId;
|
||||
repository.AddOrUpdate(mediaType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
}
|
||||
|
||||
@@ -1235,7 +1235,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
//save it all in one go
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
UpdateContentXmlStructure(asArray.Cast<IContentTypeBase>().ToArray());
|
||||
@@ -1264,7 +1264,7 @@ namespace Umbraco.Core.Services
|
||||
var repository = uow.CreateRepository<IMediaTypeRepository>();
|
||||
|
||||
repository.Delete(mediaType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedMediaType.RaiseEvent(new DeleteEventArgs<IMediaType>(mediaType, false), this);
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
repository.Delete(mediaType);
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedMediaType.RaiseEvent(new DeleteEventArgs<IMediaType>(asArray, false), this);
|
||||
}
|
||||
@@ -1361,7 +1361,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
repo.AddOrUpdate(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
SavedContainer.RaiseEvent(new SaveEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
//TODO: Audit trail ?
|
||||
@@ -146,7 +146,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IDataTypeContainerRepository>();
|
||||
repo.AddOrUpdate(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedContainer.RaiseEvent(new SaveEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
@@ -173,7 +173,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
repo.Delete(container);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
DeletedContainer.RaiseEvent(new DeleteEventArgs<EntityContainer>(container, evtMsgs), this);
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace Umbraco.Core.Services
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the PreValueCollection for the specified data type
|
||||
/// </summary>
|
||||
@@ -340,7 +340,7 @@ namespace Umbraco.Core.Services
|
||||
return Attempt.Fail(
|
||||
new OperationStatus<MoveOperationStatusType>(ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Moved.RaiseEvent(new MoveEventArgs<IDataTypeDefinition>(false, evtMsgs, moveInfo.ToArray()), this);
|
||||
@@ -356,19 +356,19 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="userId">Id of the user issueing the save</param>
|
||||
public void Save(IDataTypeDefinition dataTypeDefinition, int userId = 0)
|
||||
{
|
||||
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition), this))
|
||||
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition), this))
|
||||
return;
|
||||
|
||||
dataTypeDefinition.CreatorId = userId;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IDataTypeDefinitionRepository>();
|
||||
dataTypeDefinition.CreatorId = userId;
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
uow.Commit();
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition, false), this);
|
||||
Audit(AuditType.Save, string.Format("Save DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ namespace Umbraco.Core.Services
|
||||
dataTypeDefinition.CreatorId = userId;
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
if (raiseEvents)
|
||||
Saved.RaiseEvent(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinitions, false), this);
|
||||
@@ -484,7 +484,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IDataTypeDefinitionRepository>();
|
||||
repository.AddOrUpdatePreValues(dataTypeDefinition, values);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,23 +499,18 @@ namespace Umbraco.Core.Services
|
||||
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition), this))
|
||||
return;
|
||||
|
||||
dataTypeDefinition.CreatorId = userId;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IDataTypeDefinitionRepository>();
|
||||
dataTypeDefinition.CreatorId = userId;
|
||||
|
||||
//add/update the dtd
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
|
||||
//add/update the prevalues
|
||||
repository.AddOrUpdatePreValues(dataTypeDefinition, values);
|
||||
|
||||
uow.Commit();
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition, false), this);
|
||||
repository.AddOrUpdate(dataTypeDefinition); // definition
|
||||
repository.AddOrUpdatePreValues(dataTypeDefinition, values); //prevalues
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IDataTypeDefinition>(dataTypeDefinition, false), this);
|
||||
Audit(AuditType.Save, "Save DataTypeDefinition performed by user", userId, dataTypeDefinition.Id);
|
||||
}
|
||||
|
||||
|
||||
@@ -529,21 +524,20 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="dataTypeDefinition"><see cref="IDataTypeDefinition"/> to delete</param>
|
||||
/// <param name="userId">Optional Id of the user issueing the deletion</param>
|
||||
public void Delete(IDataTypeDefinition dataTypeDefinition, int userId = 0)
|
||||
{
|
||||
if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<IDataTypeDefinition>(dataTypeDefinition), this))
|
||||
{
|
||||
if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<IDataTypeDefinition>(dataTypeDefinition), this))
|
||||
return;
|
||||
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IDataTypeDefinitionRepository>();
|
||||
repository.Delete(dataTypeDefinition);
|
||||
|
||||
uow.Commit();
|
||||
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IDataTypeDefinition>(dataTypeDefinition, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Delete, string.Format("Delete DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IDataTypeDefinition>(dataTypeDefinition, false), this);
|
||||
|
||||
Audit(AuditType.Delete, string.Format("Delete DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
|
||||
}
|
||||
|
||||
private void Audit(AuditType type, string message, int userId, int objectId)
|
||||
@@ -552,7 +546,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IDomainRepository>();
|
||||
return repo.Exists(domainName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Attempt<OperationStatus> Delete(IDomain domain)
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IDomainRepository>();
|
||||
repository.Delete(domain);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
var args = new DeleteEventArgs<IDomain>(domain, false, evtMsgs);
|
||||
@@ -99,7 +99,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IDomainRepository>();
|
||||
repository.AddOrUpdate(domainEntity);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IDomain>(domainEntity, false, evtMsgs), this);
|
||||
@@ -109,14 +109,14 @@ namespace Umbraco.Core.Services
|
||||
#region Event Handlers
|
||||
/// <summary>
|
||||
/// Occurs before Delete
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IDomainService, DeleteEventArgs<IDomain>> Deleting;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after Delete
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IDomainService, DeleteEventArgs<IDomain>> Deleted;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Save
|
||||
/// </summary>
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IDomainService, SaveEventArgs<IDomain>> Saved;
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all logins matching the login info - generally there should only be one but in some cases
|
||||
/// Returns all logins matching the login info - generally there should only be one but in some cases
|
||||
/// there might be more than one depending on if an adminstrator has been editing/removing members
|
||||
/// </summary>
|
||||
/// <param name="login"></param>
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IExternalLoginRepository>();
|
||||
repo.SaveUserLogins(userId, logins);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IExternalLoginRepository>();
|
||||
repo.DeleteUserLogins(userId);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace Umbraco.Core.Services
|
||||
private const string PartialViewMacroHeader = "@inherits Umbraco.Web.Macros.PartialViewMacroPage";
|
||||
|
||||
public FileService(
|
||||
IUnitOfWorkProvider fileProvider,
|
||||
IDatabaseUnitOfWorkProvider dataProvider,
|
||||
IUnitOfWorkProvider fileProvider,
|
||||
IDatabaseUnitOfWorkProvider dataProvider,
|
||||
RepositoryFactory repositoryFactory,
|
||||
ILogger logger,
|
||||
IEventMessagesFactory eventMessagesFactory)
|
||||
: base(dataProvider, repositoryFactory, logger, eventMessagesFactory)
|
||||
{
|
||||
_fileUowProvider = fileProvider;
|
||||
_fileUowProvider = fileProvider;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,12 +85,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IStylesheetRepository>();
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
uow.Commit();
|
||||
|
||||
SavedStylesheet.RaiseEvent(new SaveEventArgs<Stylesheet>(stylesheet, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save Stylesheet performed by user"), userId, -1);
|
||||
SavedStylesheet.RaiseEvent(new SaveEventArgs<Stylesheet>(stylesheet, false), this);
|
||||
Audit(AuditType.Save, "Save Stylesheet performed by user", userId, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,22 +99,22 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="userId"></param>
|
||||
public void DeleteStylesheet(string path, int userId = 0)
|
||||
{
|
||||
Stylesheet stylesheet;
|
||||
using (var uow = _fileUowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IStylesheetRepository>();
|
||||
var stylesheet = repository.Get(path);
|
||||
stylesheet = repository.Get(path);
|
||||
if (stylesheet == null) return;
|
||||
|
||||
if (DeletingStylesheet.IsRaisedEventCancelled(new DeleteEventArgs<Stylesheet>(stylesheet), this))
|
||||
return;
|
||||
|
||||
repository.Delete(stylesheet);
|
||||
uow.Commit();
|
||||
|
||||
DeletedStylesheet.RaiseEvent(new DeleteEventArgs<Stylesheet>(stylesheet, false), this);
|
||||
|
||||
Audit(AuditType.Delete, string.Format("Delete Stylesheet performed by user"), userId, -1);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedStylesheet.RaiseEvent(new DeleteEventArgs<Stylesheet>(stylesheet, false), this);
|
||||
Audit(AuditType.Delete, "Delete Stylesheet performed by user", userId, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -176,11 +175,10 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IScriptRepository>();
|
||||
repository.AddOrUpdate(script);
|
||||
uow.Commit();
|
||||
|
||||
SavedScript.RaiseEvent(new SaveEventArgs<Script>(script, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedScript.RaiseEvent(new SaveEventArgs<Script>(script, false), this);
|
||||
Audit(AuditType.Save, string.Format("Save Script performed by user"), userId, -1);
|
||||
}
|
||||
|
||||
@@ -191,22 +189,23 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="userId"></param>
|
||||
public void DeleteScript(string path, int userId = 0)
|
||||
{
|
||||
Script script;
|
||||
|
||||
using (var uow = _fileUowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IScriptRepository>();
|
||||
var script = repository.Get(path);
|
||||
script = repository.Get(path);
|
||||
if (script == null) return;
|
||||
|
||||
if (DeletingScript.IsRaisedEventCancelled(new DeleteEventArgs<Script>(script), this))
|
||||
return; ;
|
||||
return;
|
||||
|
||||
repository.Delete(script);
|
||||
uow.Commit();
|
||||
|
||||
DeletedScript.RaiseEvent(new DeleteEventArgs<Script>(script, false), this);
|
||||
|
||||
Audit(AuditType.Delete, string.Format("Delete Script performed by user"), userId, -1);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedScript.RaiseEvent(new DeleteEventArgs<Script>(script, false), this);
|
||||
Audit(AuditType.Delete, string.Format("Delete Script performed by user"), userId, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -228,8 +227,8 @@ namespace Umbraco.Core.Services
|
||||
using (var uow = _fileUowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IScriptRepository>();
|
||||
((ScriptRepository)repository).AddFolder(folderPath);
|
||||
uow.Commit();
|
||||
((ScriptRepository) repository).AddFolder(folderPath);
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,8 +237,8 @@ namespace Umbraco.Core.Services
|
||||
using (var uow = _fileUowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IScriptRepository>();
|
||||
((ScriptRepository)repository).DeleteFolder(folderPath);
|
||||
uow.Commit();
|
||||
((ScriptRepository) repository).DeleteFolder(folderPath);
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,12 +286,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<ITemplateRepository>();
|
||||
repository.AddOrUpdate(template);
|
||||
uow.Commit();
|
||||
|
||||
SavedTemplate.RaiseEvent(new SaveEventArgs<ITemplate>(template, false, evtMsgs), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save Template performed by user"), userId, template.Id);
|
||||
SavedTemplate.RaiseEvent(new SaveEventArgs<ITemplate>(template, false, evtMsgs), this);
|
||||
Audit(AuditType.Save, "Save Template performed by user", userId, template.Id);
|
||||
|
||||
return Attempt.Succeed(new OperationStatus<ITemplate, OperationStatusType>(template, OperationStatusType.Success, evtMsgs));
|
||||
}
|
||||
@@ -478,12 +476,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<ITemplateRepository>();
|
||||
repository.AddOrUpdate(template);
|
||||
uow.Commit();
|
||||
|
||||
SavedTemplate.RaiseEvent(new SaveEventArgs<ITemplate>(template, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save Template performed by user"), userId, template.Id);
|
||||
SavedTemplate.RaiseEvent(new SaveEventArgs<ITemplate>(template, false), this);
|
||||
Audit(AuditType.Save, "Save Template performed by user", userId, template.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -500,28 +497,25 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<ITemplateRepository>();
|
||||
foreach (var template in templates)
|
||||
{
|
||||
repository.AddOrUpdate(template);
|
||||
}
|
||||
uow.Commit();
|
||||
|
||||
SavedTemplate.RaiseEvent(new SaveEventArgs<ITemplate>(templates, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save Template performed by user"), userId, -1);
|
||||
SavedTemplate.RaiseEvent(new SaveEventArgs<ITemplate>(templates, false), this);
|
||||
Audit(AuditType.Save, "Save Template performed by user", userId, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
|
||||
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
|
||||
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
|
||||
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
|
||||
/// rendering engine to use.
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
|
||||
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
|
||||
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
|
||||
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
|
||||
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
|
||||
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
|
||||
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
|
||||
/// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
|
||||
/// </remarks>
|
||||
public RenderingEngine DetermineTemplateRenderingEngine(ITemplate template)
|
||||
@@ -540,22 +534,22 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="userId"></param>
|
||||
public void DeleteTemplate(string alias, int userId = 0)
|
||||
{
|
||||
ITemplate template;
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<ITemplateRepository>();
|
||||
var template = repository.Get(alias);
|
||||
template = repository.Get(alias);
|
||||
if (template == null) return;
|
||||
|
||||
if (DeletingTemplate.IsRaisedEventCancelled(new DeleteEventArgs<ITemplate>(template), this))
|
||||
return;
|
||||
|
||||
repository.Delete(template);
|
||||
uow.Commit();
|
||||
|
||||
DeletedTemplate.RaiseEvent(new DeleteEventArgs<ITemplate>(template, false), this);
|
||||
|
||||
Audit(AuditType.Delete, string.Format("Delete Template performed by user"), userId, template.Id);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedTemplate.RaiseEvent(new DeleteEventArgs<ITemplate>(template, false), this);
|
||||
Audit(AuditType.Delete, "Delete Template performed by user", userId, template.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -590,16 +584,15 @@ namespace Umbraco.Core.Services
|
||||
.ToArray();
|
||||
|
||||
return empty.Union(files.Except(empty));
|
||||
}
|
||||
}
|
||||
|
||||
public void DeletePartialViewFolder(string folderPath)
|
||||
{
|
||||
using (var uow = _fileUowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IPartialViewRepository>();
|
||||
|
||||
((PartialViewRepository) repository).DeleteFolder(folderPath);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +602,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IPartialViewMacroRepository>();
|
||||
((PartialViewMacroRepository) repository).DeleteFolder(folderPath);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,9 +667,9 @@ namespace Umbraco.Core.Services
|
||||
|
||||
//strip the @inherits if it's there
|
||||
snippetContent = StripPartialViewHeader(snippetContent);
|
||||
|
||||
|
||||
var content = string.Format("{0}{1}{2}",
|
||||
partialViewHeader,
|
||||
partialViewHeader,
|
||||
Environment.NewLine, snippetContent);
|
||||
partialView.Content = content;
|
||||
}
|
||||
@@ -686,13 +679,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreatePartialViewRepository(partialViewType);
|
||||
repository.AddOrUpdate(partialView);
|
||||
uow.Commit();
|
||||
|
||||
CreatedPartialView.RaiseEvent(new NewEventArgs<IPartialView>(partialView, false, partialView.Alias, -1), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save {0} performed by user", partialViewType), userId, -1);
|
||||
|
||||
CreatedPartialView.RaiseEvent(new NewEventArgs<IPartialView>(partialView, false, partialView.Alias, -1), this);
|
||||
Audit(AuditType.Save, $"Save {partialViewType} performed by user", userId, -1);
|
||||
return Attempt<IPartialView>.Succeed(partialView);
|
||||
}
|
||||
|
||||
@@ -708,10 +699,11 @@ namespace Umbraco.Core.Services
|
||||
|
||||
private bool DeletePartialViewMacro(string path, PartialViewType partialViewType, int userId = 0)
|
||||
{
|
||||
IPartialView partialView;
|
||||
using (var uow = _fileUowProvider.GetUnitOfWork())
|
||||
{
|
||||
{
|
||||
var repository = uow.CreatePartialViewRepository(partialViewType);
|
||||
var partialView = repository.Get(path);
|
||||
partialView = repository.Get(path);
|
||||
if (partialView == null)
|
||||
return true;
|
||||
|
||||
@@ -719,15 +711,12 @@ namespace Umbraco.Core.Services
|
||||
return false;
|
||||
|
||||
repository.Delete(partialView);
|
||||
uow.Commit();
|
||||
|
||||
DeletedPartialView.RaiseEvent(new DeleteEventArgs<IPartialView>(partialView, false), this);
|
||||
|
||||
Audit(AuditType.Delete, string.Format("Delete {0} performed by user", partialViewType), userId, -1);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedPartialView.RaiseEvent(new DeleteEventArgs<IPartialView>(partialView, false), this);
|
||||
Audit(AuditType.Delete, $"Delete {partialViewType} performed by user", userId, -1);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = 0)
|
||||
@@ -749,13 +738,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreatePartialViewRepository(partialViewType);
|
||||
repository.AddOrUpdate(partialView);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, string.Format("Save {0} performed by user", partialViewType), userId, -1);
|
||||
|
||||
Audit(AuditType.Save, $"Save {partialViewType} performed by user", userId, -1);
|
||||
SavedPartialView.RaiseEvent(new SaveEventArgs<IPartialView>(partialView, false), this);
|
||||
|
||||
return Attempt.Succeed(partialView);
|
||||
}
|
||||
|
||||
@@ -804,7 +791,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +800,7 @@ namespace Umbraco.Core.Services
|
||||
#region Event Handlers
|
||||
/// <summary>
|
||||
/// Occurs before Delete
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IFileService, DeleteEventArgs<ITemplate>> DeletingTemplate;
|
||||
|
||||
/// <summary>
|
||||
@@ -823,7 +810,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Delete
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IFileService, DeleteEventArgs<Script>> DeletingScript;
|
||||
|
||||
/// <summary>
|
||||
@@ -833,7 +820,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Delete
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IFileService, DeleteEventArgs<Stylesheet>> DeletingStylesheet;
|
||||
|
||||
/// <summary>
|
||||
@@ -880,7 +867,7 @@ namespace Umbraco.Core.Services
|
||||
/// Occurs after Save
|
||||
/// </summary>
|
||||
public static event TypedEventHandler<IFileService, SaveEventArgs<IPartialView>> SavedPartialView;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before Create
|
||||
/// </summary>
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace Umbraco.Core.Services
|
||||
/// <returns></returns>
|
||||
public IDictionaryItem CreateDictionaryItemWithIdentity(string key, Guid? parentId, string defaultValue = null)
|
||||
{
|
||||
DictionaryItem item;
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IDictionaryRepository>();
|
||||
@@ -77,7 +78,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
var item = new DictionaryItem(parentId, key);
|
||||
item = new DictionaryItem(parentId, key);
|
||||
|
||||
if (defaultValue.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
@@ -93,15 +94,14 @@ namespace Umbraco.Core.Services
|
||||
return item;
|
||||
|
||||
repository.AddOrUpdate(item);
|
||||
uow.Commit();
|
||||
|
||||
//ensure the lazy Language callback is assigned
|
||||
EnsureDictionaryItemLanguageCallback(item);
|
||||
|
||||
SavedDictionaryItem.RaiseEvent(new SaveEventArgs<IDictionaryItem>(item), this);
|
||||
|
||||
return item;
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
// ensure the lazy Language callback is assigned
|
||||
EnsureDictionaryItemLanguageCallback(item);
|
||||
|
||||
SavedDictionaryItem.RaiseEvent(new SaveEventArgs<IDictionaryItem>(item), this);
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,13 +235,13 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IDictionaryRepository>();
|
||||
repository.AddOrUpdate(dictionaryItem);
|
||||
uow.Commit();
|
||||
//ensure the lazy Language callback is assigned
|
||||
EnsureDictionaryItemLanguageCallback(dictionaryItem);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedDictionaryItem.RaiseEvent(new SaveEventArgs<IDictionaryItem>(dictionaryItem, false), this);
|
||||
// ensure the lazy Language callback is assigned
|
||||
EnsureDictionaryItemLanguageCallback(dictionaryItem);
|
||||
|
||||
SavedDictionaryItem.RaiseEvent(new SaveEventArgs<IDictionaryItem>(dictionaryItem, false), this);
|
||||
Audit(AuditType.Save, "Save DictionaryItem performed by user", userId, dictionaryItem.Id);
|
||||
}
|
||||
|
||||
@@ -259,13 +259,11 @@ namespace Umbraco.Core.Services
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IDictionaryRepository>();
|
||||
//NOTE: The recursive delete is done in the repository
|
||||
repository.Delete(dictionaryItem);
|
||||
uow.Commit();
|
||||
repository.Delete(dictionaryItem); // recursive delete
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedDictionaryItem.RaiseEvent(new DeleteEventArgs<IDictionaryItem>(dictionaryItem, false), this);
|
||||
|
||||
Audit(AuditType.Delete, "Delete DictionaryItem performed by user", userId, dictionaryItem.Id);
|
||||
}
|
||||
|
||||
@@ -339,7 +337,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<ILanguageRepository>();
|
||||
repository.AddOrUpdate(language);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedLanguage.RaiseEvent(new SaveEventArgs<ILanguage>(language, false), this);
|
||||
@@ -362,7 +360,7 @@ namespace Umbraco.Core.Services
|
||||
var repository = uow.CreateRepository<ILanguageRepository>();
|
||||
//NOTE: There isn't any constraints in the db, so possible references aren't deleted
|
||||
repository.Delete(language);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedLanguage.RaiseEvent(new DeleteEventArgs<ILanguage>(language, false), this);
|
||||
@@ -376,7 +374,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,9 +391,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
item.GetLanguage = GetLanguageById;
|
||||
foreach (var trans in item.Translations.OfType<DictionaryTranslation>())
|
||||
{
|
||||
trans.GetLanguage = GetLanguageById;
|
||||
}
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
@@ -120,12 +120,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMacroRepository>();
|
||||
repository.Delete(macro);
|
||||
uow.Commit();
|
||||
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IMacro>(macro, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Delete, "Delete Macro performed by user", userId, -1);
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IMacro>(macro, false), this);
|
||||
Audit(AuditType.Delete, "Delete Macro performed by user", userId, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,12 +141,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMacroRepository>();
|
||||
repository.AddOrUpdate(macro);
|
||||
uow.Commit();
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMacro>(macro, false), this);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Audit(AuditType.Save, "Save Macro performed by user", userId, -1);
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMacro>(macro, false), this);
|
||||
Audit(AuditType.Save, "Save Macro performed by user", userId, -1);
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
@@ -175,7 +173,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,14 +166,12 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);
|
||||
|
||||
Created.RaiseEvent(new NewEventArgs<IMedia>(media, false, mediaTypeAlias, parentId), this);
|
||||
|
||||
Audit(AuditType.New, string.Format("Media '{0}' was created with Id {1}", name, media.Id), media.CreatorId, media.Id);
|
||||
Audit(AuditType.New, $"Media '{name}' was created with Id {media.Id}", media.CreatorId, media.Id);
|
||||
|
||||
return media;
|
||||
}
|
||||
@@ -224,15 +222,12 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);
|
||||
|
||||
Created.RaiseEvent(new NewEventArgs<IMedia>(media, false, mediaTypeAlias, parent), this);
|
||||
|
||||
Audit(AuditType.New, string.Format("Media '{0}' was created with Id {1}", name, media.Id), media.CreatorId, media.Id);
|
||||
|
||||
Audit(AuditType.New, $"Media '{name}' was created with Id {media.Id}", media.CreatorId, media.Id);
|
||||
return media;
|
||||
}
|
||||
|
||||
@@ -736,7 +731,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMediaRepository>();
|
||||
repository.Delete(media);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
var args = new DeleteEventArgs<IMedia>(media, false, evtMsgs);
|
||||
Deleted.RaiseEvent(args, this);
|
||||
@@ -783,12 +778,11 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, _urlSegmentProviders, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false, evtMsgs), this);
|
||||
|
||||
Audit(AuditType.Save, "Save Media performed by user", userId, media.Id);
|
||||
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
@@ -831,12 +825,11 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
//commit the whole lot in one go
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMedia>(asArray, false, evtMsgs), this);
|
||||
|
||||
Audit(AuditType.Save, "Save Media items performed by user", userId, -1);
|
||||
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
@@ -975,12 +968,11 @@ namespace Umbraco.Core.Services
|
||||
moveInfo.Add(new MoveEventInfo<IMedia>(descendant, descendant.Path, descendant.ParentId));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Trashed.RaiseEvent(
|
||||
new MoveEventArgs<IMedia>(false, evtMsgs, moveInfo.ToArray()), this);
|
||||
|
||||
Audit(AuditType.Move, "Move Media to Recycle Bin performed by user", userId, media.Id);
|
||||
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
@@ -1018,11 +1010,10 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMediaRepository>();
|
||||
repository.DeleteVersions(id, versionDate);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedVersions.RaiseEvent(new DeleteRevisionsEventArgs(id, false, dateToRetain: versionDate), this);
|
||||
|
||||
Audit(AuditType.Delete, "Delete Media by version date performed by user", userId, -1);
|
||||
}
|
||||
|
||||
@@ -1049,11 +1040,10 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMediaRepository>();
|
||||
repository.DeleteVersion(versionId);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedVersions.RaiseEvent(new DeleteRevisionsEventArgs(id, false, specificVersion: versionId), this);
|
||||
|
||||
Audit(AuditType.Delete, "Delete Media by version performed by user", userId, -1);
|
||||
}
|
||||
|
||||
@@ -1124,12 +1114,11 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMedia>(asArray, false), this);
|
||||
|
||||
Audit(AuditType.Sort, "Sorting Media performed by user", userId, 0);
|
||||
|
||||
return true;
|
||||
@@ -1227,7 +1216,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMemberGroupRepository>();
|
||||
repository.AddOrUpdate(memberGroup);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMemberGroupRepository>();
|
||||
repository.Delete(memberGroup);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IMemberGroup>(memberGroup, false), this);
|
||||
|
||||
@@ -886,7 +886,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdatePreviewXml(member, m => _entitySerializer.Serialize(_dataTypeService, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMember>(member, false), this);
|
||||
@@ -967,7 +967,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMemberRepository>();
|
||||
repository.Delete(member);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
var args = new DeleteEventArgs<IMember>(member, false);
|
||||
Deleted.RaiseEvent(args, this);
|
||||
@@ -1004,7 +1004,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdatePreviewXml(entity, m => _entitySerializer.Serialize(_dataTypeService, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -1043,7 +1043,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
//commit the whole lot in one go
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -1228,7 +1228,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IAuditRepository>();
|
||||
repo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Core.Services
|
||||
memberType.CreatorId = userId;
|
||||
repository.AddOrUpdate(memberType);
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
UpdateContentXmlStructure(memberType);
|
||||
@@ -117,7 +117,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
//save it all in one go
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
UpdateContentXmlStructure(asArray.Cast<IContentTypeBase>().ToArray());
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IMemberTypeRepository>();
|
||||
repository.Delete(memberType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IMemberType>(memberType, false), this);
|
||||
}
|
||||
@@ -167,10 +167,10 @@ namespace Umbraco.Core.Services
|
||||
repository.Delete(memberType);
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IMemberType>(asArray, false), this);
|
||||
}
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<IMemberType>(asArray, false), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IMigrationEntryRepository>();
|
||||
repo.AddOrUpdate(entry);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
||||
@@ -119,11 +119,12 @@ namespace Umbraco.Core.Services
|
||||
public Attempt<OperationStatus<PublicAccessEntry, OperationStatusType>> AddRule(IContent content, string ruleType, string ruleValue)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
PublicAccessEntry entry;
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repo = uow.CreateRepository<IPublicAccessRepository>();
|
||||
|
||||
var entry = repo.GetAll().FirstOrDefault(x => x.ProtectedNodeId == content.Id);
|
||||
entry = repo.GetAll().FirstOrDefault(x => x.ProtectedNodeId == content.Id);
|
||||
if (entry == null)
|
||||
return Attempt<OperationStatus<PublicAccessEntry, OperationStatusType>>.Fail();
|
||||
|
||||
@@ -149,12 +150,12 @@ namespace Umbraco.Core.Services
|
||||
|
||||
repo.AddOrUpdate(entry);
|
||||
|
||||
uow.Commit();
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<PublicAccessEntry>(entry, false, evtMsgs), this);
|
||||
return Attempt<OperationStatus<PublicAccessEntry, OperationStatusType>>.Succeed(
|
||||
new OperationStatus<PublicAccessEntry, OperationStatusType>(entry, OperationStatusType.Success, evtMsgs));
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<PublicAccessEntry>(entry, false, evtMsgs), this);
|
||||
return Attempt<OperationStatus<PublicAccessEntry, OperationStatusType>>.Succeed(
|
||||
new OperationStatus<PublicAccessEntry, OperationStatusType>(entry, OperationStatusType.Success, evtMsgs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,11 +167,12 @@ namespace Umbraco.Core.Services
|
||||
public Attempt<OperationStatus> RemoveRule(IContent content, string ruleType, string ruleValue)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
PublicAccessEntry entry;
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repo = uow.CreateRepository<IPublicAccessRepository>();
|
||||
|
||||
var entry = repo.GetAll().FirstOrDefault(x => x.ProtectedNodeId == content.Id);
|
||||
entry = repo.GetAll().FirstOrDefault(x => x.ProtectedNodeId == content.Id);
|
||||
if (entry == null) return Attempt<OperationStatus>.Fail();
|
||||
|
||||
var existingRule = entry.Rules.FirstOrDefault(x => x.RuleType == ruleType && x.RuleValue == ruleValue);
|
||||
@@ -178,21 +180,15 @@ namespace Umbraco.Core.Services
|
||||
|
||||
entry.RemoveRule(existingRule);
|
||||
|
||||
if (Saving.IsRaisedEventCancelled(
|
||||
new SaveEventArgs<PublicAccessEntry>(entry, evtMsgs),
|
||||
this))
|
||||
{
|
||||
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<PublicAccessEntry>(entry, evtMsgs), this))
|
||||
return OperationStatus.Cancelled(evtMsgs);
|
||||
}
|
||||
|
||||
repo.AddOrUpdate(entry);
|
||||
|
||||
uow.Commit();
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<PublicAccessEntry>(entry, false, evtMsgs), this);
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<PublicAccessEntry>(entry, false, evtMsgs), this);
|
||||
return OperationStatus.Success(evtMsgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -213,7 +209,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IPublicAccessRepository>();
|
||||
repo.AddOrUpdate(entry);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<PublicAccessEntry>(entry, false, evtMsgs), this);
|
||||
@@ -238,7 +234,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<IPublicAccessRepository>();
|
||||
repo.Delete(entry);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
Deleted.RaiseEvent(new DeleteEventArgs<PublicAccessEntry>(entry, false, evtMsgs), this);
|
||||
|
||||
@@ -403,7 +403,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IRelationRepository>();
|
||||
repository.AddOrUpdate(relation);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedRelation.RaiseEvent(new SaveEventArgs<IRelation>(relation, false), this);
|
||||
@@ -431,7 +431,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IRelationRepository>();
|
||||
repository.AddOrUpdate(relation);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedRelation.RaiseEvent(new SaveEventArgs<IRelation>(relation, false), this);
|
||||
@@ -555,7 +555,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IRelationRepository>();
|
||||
repository.AddOrUpdate(relation);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedRelation.RaiseEvent(new SaveEventArgs<IRelation>(relation, false), this);
|
||||
@@ -574,7 +574,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IRelationTypeRepository>();
|
||||
repository.AddOrUpdate(relationType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedRelationType.RaiseEvent(new SaveEventArgs<IRelationType>(relationType, false), this);
|
||||
@@ -593,7 +593,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IRelationRepository>();
|
||||
repository.Delete(relation);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedRelation.RaiseEvent(new DeleteEventArgs<IRelation>(relation, false), this);
|
||||
@@ -612,7 +612,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IRelationTypeRepository>();
|
||||
repository.Delete(relationType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedRelationType.RaiseEvent(new DeleteEventArgs<IRelationType>(relationType, false), this);
|
||||
@@ -632,10 +632,9 @@ namespace Umbraco.Core.Services
|
||||
relations.AddRange(repository.GetByQuery(query).ToList());
|
||||
|
||||
foreach (var relation in relations)
|
||||
{
|
||||
repository.Delete(relation);
|
||||
}
|
||||
uow.Commit();
|
||||
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedRelation.RaiseEvent(new DeleteEventArgs<IRelation>(relations, false), this);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Core.Services
|
||||
server.IsMaster = true;
|
||||
|
||||
repo.AddOrUpdate(server);
|
||||
uow.Commit(); // triggers a cache reload
|
||||
uow.Flush(); // triggers a cache reload
|
||||
// fixme - this will release the log since we commited the uow?!
|
||||
repo.DeactiveStaleServers(staleTimeout); // triggers a cache reload
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Core.Services
|
||||
? (server.IsMaster ? ServerRole.Master : ServerRole.Slave)
|
||||
: ServerRole.Single;
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Umbraco.Core.Services
|
||||
server.IsActive = server.IsMaster = false;
|
||||
repo.AddOrUpdate(server); // will trigger a cache reload
|
||||
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<ITaskTypeRepository>();
|
||||
repo.AddOrUpdate(taskType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<ITaskTypeRepository>();
|
||||
repo.Delete(taskTypeEntity);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<ITaskRepository>();
|
||||
repo.AddOrUpdate(task);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repo = uow.CreateRepository<ITaskRepository>();
|
||||
repo.Delete(task);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
//TODO: PUT lock here!!
|
||||
|
||||
User user;
|
||||
using (var uow = UowProvider.GetUnitOfWork())
|
||||
{
|
||||
var repository = uow.CreateRepository<IUserRepository>();
|
||||
@@ -137,7 +138,7 @@ namespace Umbraco.Core.Services
|
||||
if (loginExists)
|
||||
throw new ArgumentException("Login already exists");
|
||||
|
||||
var user = new User(userType)
|
||||
user = new User(userType)
|
||||
{
|
||||
DefaultToLiveEditing = false,
|
||||
Email = email,
|
||||
@@ -159,12 +160,11 @@ namespace Umbraco.Core.Services
|
||||
return user;
|
||||
|
||||
repository.AddOrUpdate(user);
|
||||
uow.Commit();
|
||||
|
||||
SavedUser.RaiseEvent(new SaveEventArgs<IUser>(user, false), this);
|
||||
|
||||
return user;
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
SavedUser.RaiseEvent(new SaveEventArgs<IUser>(user, false), this);
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -298,7 +298,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IUserRepository>();
|
||||
repository.Delete(user);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedUser.RaiseEvent(new DeleteEventArgs<IUser>(user, false), this);
|
||||
@@ -325,7 +325,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdate(entity);
|
||||
try
|
||||
{
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
catch (DbException ex)
|
||||
{
|
||||
@@ -363,7 +363,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdate(member);
|
||||
}
|
||||
//commit the whole lot in one go
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -664,7 +664,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IUserTypeRepository>();
|
||||
repository.AddOrUpdate(userType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (raiseEvents)
|
||||
@@ -684,7 +684,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var repository = uow.CreateRepository<IUserTypeRepository>();
|
||||
repository.Delete(userType);
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
DeletedUserType.RaiseEvent(new DeleteEventArgs<IUserType>(userType, false), this);
|
||||
@@ -707,7 +707,7 @@ namespace Umbraco.Core.Services
|
||||
user.RemoveAllowedSection(sectionAlias);
|
||||
repository.AddOrUpdate(user);
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,7 +737,7 @@ namespace Umbraco.Core.Services
|
||||
user.AddAllowedSection(sectionAlias);
|
||||
repository.AddOrUpdate(user);
|
||||
}
|
||||
uow.Commit();
|
||||
uow.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -415,8 +415,6 @@
|
||||
<Compile Include="Persistence\Factories\PublicAccessEntryFactory.cs" />
|
||||
<Compile Include="Persistence\Factories\TaskFactory.cs" />
|
||||
<Compile Include="Persistence\Factories\TaskTypeFactory.cs" />
|
||||
<Compile Include="Persistence\LockedRepository.cs" />
|
||||
<Compile Include="Persistence\LockingRepository.cs" />
|
||||
<Compile Include="Persistence\Mappers\AccessMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\DomainMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\MigrationEntryMapper.cs" />
|
||||
@@ -491,6 +489,7 @@
|
||||
<Compile Include="Persistence\Repositories\TupleExtensions.cs" />
|
||||
<Compile Include="Persistence\SqlContext.cs" />
|
||||
<Compile Include="Persistence\NPocoSqlExtensions.cs" />
|
||||
<Compile Include="Persistence\UnitOfWork\UnitOfWorkBase.cs" />
|
||||
<Compile Include="PropertyEditors\DecimalValidator.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\GridValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\DecimalValueConverter.cs" />
|
||||
@@ -1053,7 +1052,6 @@
|
||||
<Compile Include="Persistence\SqlSyntax\SqlServerSyntaxProvider.cs" />
|
||||
<Compile Include="Persistence\SqlSyntax\SqlSyntaxProviderAttribute.cs" />
|
||||
<Compile Include="Persistence\SqlSyntax\SqlSyntaxProviderBase.cs" />
|
||||
<Compile Include="Persistence\TransactionType.cs" />
|
||||
<Compile Include="Persistence\UmbracoDatabase.cs" />
|
||||
<Compile Include="Persistence\UnitOfWork\FileUnitOfWork.cs" />
|
||||
<Compile Include="Persistence\UnitOfWork\FileUnitOfWorkProvider.cs" />
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var repo = new AuditRepository(unitOfWork, CacheHelper, Logger, MappingResolver);
|
||||
repo.AddOrUpdate(new AuditItem(-1, "This is a System audit trail", AuditType.System, 0));
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
|
||||
var dtos = DatabaseContext.Database.Fetch<LogDto>("WHERE id > -1");
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//now create some versions of this content - this shouldn't affect the xml structures saved
|
||||
for (int i = 0; i < allCreated.Count; i++)
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
allCreated[i].ChangePublishedState(PublishedState.Saved);
|
||||
repository.AddOrUpdate(allCreated[i]);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -107,6 +107,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.RebuildXmlStructures(media => new XElement("test"), 10);
|
||||
|
||||
Assert.AreEqual(100, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +139,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//now create some versions of this content - this shouldn't affect the xml structures saved
|
||||
for (int i = 0; i < allCreated.Count; i++)
|
||||
@@ -145,7 +147,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
allCreated[i].Name = "blah" + i;
|
||||
repository.AddOrUpdate(allCreated[i]);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -154,6 +156,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.RebuildXmlStructures(media => new XElement("test"), 10);
|
||||
|
||||
Assert.AreEqual(100, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +206,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//now create some versions of this content - this shouldn't affect the xml structures saved
|
||||
for (int i = 0; i < allCreated.Count; i++)
|
||||
@@ -210,7 +214,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
allCreated[i].Name = "blah" + i;
|
||||
repository.AddOrUpdate(allCreated[i]);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -219,6 +223,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.RebuildXmlStructures(media => new XElement("test"), 10, contentTypeIds: new[] { contentType1.Id, contentType2.Id });
|
||||
|
||||
Assert.AreEqual(60, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,20 +245,21 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var parentPage = MockedContent.CreateSimpleContent(contentType);
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
repository.AddOrUpdate(parentPage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
repository.AssignEntityPermission(parentPage, 'A', new int[] { 0 });
|
||||
var childPage = MockedContent.CreateSimpleContent(contentType, "child", parentPage);
|
||||
repository.AddOrUpdate(childPage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var permissions = repository.GetPermissionsForEntity(childPage.Id);
|
||||
Assert.AreEqual(1, permissions.Count());
|
||||
Assert.AreEqual("A", permissions.Single().AssignedPermissions.First());
|
||||
}
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -270,7 +277,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
repository.AddOrUpdate(textpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Complete();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.HasIdentity, Is.True);
|
||||
@@ -292,7 +299,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var template = new Template("hello", "hello");
|
||||
templateRepository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage2", "Textpage");
|
||||
contentType.AllowedTemplates = Enumerable.Empty<ITemplate>(); // because CreateSimple... assigns one
|
||||
@@ -303,11 +310,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
repository.AddOrUpdate(textpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(textpage.Template, Is.Not.Null);
|
||||
Assert.That(textpage.Template, Is.EqualTo(contentType.DefaultTemplate));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +332,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork, out contentTypeRepository);
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage1", "Textpage");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var textpage = MockedContent.CreateSimpleContent(contentType, "test@umbraco.org", -1);
|
||||
var anotherTextpage = MockedContent.CreateSimpleContent(contentType, "@lightgiants", -1);
|
||||
@@ -332,7 +341,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(textpage);
|
||||
repository.AddOrUpdate(anotherTextpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.HasIdentity, Is.True);
|
||||
@@ -343,6 +352,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var content2 = repository.Get(anotherTextpage.Id);
|
||||
Assert.That(content2.Name, Is.EqualTo(anotherTextpage.Name));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,11 +372,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
repository.AddOrUpdate(textpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id);
|
||||
repository.AddOrUpdate(subpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.HasIdentity, Is.True);
|
||||
@@ -408,7 +419,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var content = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
content.Name = "About 2";
|
||||
repository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var updatedContent = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
|
||||
// Assert
|
||||
@@ -431,7 +442,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var content = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
content.Template = null;
|
||||
repository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var updatedContent = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
|
||||
// Assert
|
||||
@@ -456,11 +467,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var id = content.Id;
|
||||
|
||||
repository.Delete(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var content1 = repository.Get(id);
|
||||
|
||||
@@ -528,13 +539,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
content.ChangePublishedState(PublishedState.Saved);
|
||||
repository.AddOrUpdate(content);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
foreach (var content in result)
|
||||
{
|
||||
content.ChangePublishedState(PublishedState.Published);
|
||||
repository.AddOrUpdate(content);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
|
||||
|
||||
@@ -90,13 +90,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
templateRepo.AddOrUpdate(template);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
contentType.AllowedTemplates = new[] { templates[0], templates[1] };
|
||||
contentType.SetDefaultTemplate(templates[0]);
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
var result = repository.Get(contentType.Id);
|
||||
@@ -117,16 +117,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var container1 = new EntityContainer(Constants.ObjectTypes.DocumentTypeGuid) { Name = "blah1" };
|
||||
containerRepository.AddOrUpdate(container1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var container2 = new EntityContainer(Constants.ObjectTypes.DocumentTypeGuid) { Name = "blah2", ParentId = container1.Id };
|
||||
containerRepository.AddOrUpdate(container2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType = (IContentType)MockedContentTypes.CreateBasicContentType("asdfasdf");
|
||||
contentType.ParentId = container2.Id;
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//create a
|
||||
var contentType2 = (IContentType)new ContentType(contentType, "hello")
|
||||
@@ -135,10 +135,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
contentType.ParentId = contentType.Id;
|
||||
repository.AddOrUpdate(contentType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.Move(contentType, container1).ToArray();
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(2, result.Count());
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var containerRepository = CreateContainerRepository(unitOfWork, Constants.ObjectTypes.DocumentTypeContainerGuid);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DocumentTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.That(container.Id, Is.GreaterThan(0));
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
@@ -179,11 +179,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var containerRepository = CreateContainerRepository(unitOfWork, Constants.ObjectTypes.DocumentTypeContainerGuid);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DocumentTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
containerRepository.Delete(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
Assert.IsNull(found);
|
||||
@@ -200,12 +200,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test", propertyGroupName: "testGroup");
|
||||
contentType.ParentId = container.Id;
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(container.Id, contentType.ParentId);
|
||||
}
|
||||
@@ -221,16 +221,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateMediaTypeRepository(unitOfWork);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
IMediaType contentType = MockedContentTypes.CreateSimpleMediaType("test", "Test", propertyGroupName: "testGroup");
|
||||
contentType.ParentId = container.Id;
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
containerRepository.Delete(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
Assert.IsNull(found);
|
||||
@@ -252,7 +252,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test", propertyGroupName: "testGroup");
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.HasIdentity, Is.True);
|
||||
@@ -294,7 +294,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.AreEqual(4, mapped.PropertyTypes.Count());
|
||||
|
||||
repository.AddOrUpdate(mapped);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(4, mapped.PropertyTypes.Count());
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
DataTypeDefinitionId = -88
|
||||
});
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dirty = ((ICanBeDirty)contentType).IsDirty();
|
||||
|
||||
@@ -440,7 +440,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.IsTrue(mapped.PropertyTypes.Any(x => x.Alias == "subtitle"));
|
||||
|
||||
repository.AddOrUpdate(mapped);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dirty = mapped.IsDirty();
|
||||
|
||||
@@ -471,11 +471,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType2 = repository.Get(contentType.Id);
|
||||
repository.Delete(contentType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(contentType.Id);
|
||||
|
||||
@@ -499,13 +499,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(ctMain);
|
||||
repository.AddOrUpdate(ctChild1);
|
||||
repository.AddOrUpdate(ctChild2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
|
||||
var resolvedParent = repository.Get(ctMain.Id);
|
||||
repository.Delete(resolvedParent);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(repository.Exists(ctMain.Id), Is.False);
|
||||
@@ -529,7 +529,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(child3);
|
||||
var child2 = MockedContentTypes.CreateSimpleContentType("a123", "a123", contentType, randomizeAliases: true);
|
||||
repository.AddOrUpdate(child2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var contentTypes = repository.GetByQuery(repository.Query.Where(x => x.ParentId == contentType.Id));
|
||||
@@ -572,7 +572,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
|
||||
var childContentType = MockedContentTypes.CreateSimpleContentType("blah", "Blah", contentType, randomizeAliases:true);
|
||||
repository.AddOrUpdate(childContentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var result = repository.Get(childContentType.Key);
|
||||
@@ -674,7 +674,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
contentType.PropertyGroups["Meta"].PropertyTypes.Remove("description");
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.Get(NodeDto.NodeIdSeed + 1);
|
||||
|
||||
@@ -743,7 +743,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var addedPropertyType = contentType.AddPropertyType(urlAlias);
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var updated = repository.Get(NodeDto.NodeIdSeed + 1);
|
||||
@@ -768,7 +768,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var simpleSubpageContentType = MockedContentTypes.CreateSimpleContentType("umbSimpleSubpage", "Simple Subpage");
|
||||
repository.AddOrUpdate(subpageContentType);
|
||||
repository.AddOrUpdate(simpleSubpageContentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var contentType = repository.Get(NodeDto.NodeIdSeed);
|
||||
@@ -778,7 +778,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
new ContentTypeSort(new Lazy<int>(() => simpleSubpageContentType.Id), 1, simpleSubpageContentType.Alias)
|
||||
};
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
var updated = repository.Get(NodeDto.NodeIdSeed);
|
||||
@@ -802,12 +802,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
|
||||
contentRepository.AddOrUpdate(subpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
contentType.RemovePropertyType("keywords");
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(3));
|
||||
@@ -829,13 +829,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
|
||||
contentRepository.AddOrUpdate(subpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta");
|
||||
propertyGroup.PropertyTypes.Add(new PropertyType("test", DataTypeDatabaseType.Ntext, "metaAuthor") { Name = "Meta Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(5));
|
||||
@@ -857,18 +857,18 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
|
||||
contentRepository.AddOrUpdate(subpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta");
|
||||
propertyGroup.PropertyTypes.Add(new PropertyType("test", DataTypeDatabaseType.Ntext, "metaAuthor") { Name = "Meta Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var content = contentRepository.Get(subpage.Id);
|
||||
content.SetValue("metaAuthor", "John Doe");
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
var updated = contentRepository.Get(subpage.Id);
|
||||
@@ -891,7 +891,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var subpage = MockedContent.CreateTextpageContent(contentType, "Text Page 1", contentType.Id);
|
||||
contentRepository.AddOrUpdate(subpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Remove PropertyType
|
||||
contentType.RemovePropertyType("keywords");
|
||||
@@ -899,13 +899,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta");
|
||||
propertyGroup.PropertyTypes.Add(new PropertyType("test", DataTypeDatabaseType.Ntext, "metaAuthor") { Name = "Meta Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var content = contentRepository.Get(subpage.Id);
|
||||
content.SetValue("metaAuthor", "John Doe");
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
var updated = contentRepository.Get(subpage.Id);
|
||||
|
||||
@@ -89,18 +89,18 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var container1 = new EntityContainer(Constants.ObjectTypes.DataTypeGuid) { Name = "blah1" };
|
||||
containerRepository.AddOrUpdate(container1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var container2 = new EntityContainer(Constants.ObjectTypes.DataTypeGuid) { Name = "blah2", ParentId = container1.Id };
|
||||
containerRepository.AddOrUpdate(container2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dataType = (IDataTypeDefinition)new DataTypeDefinition(container2.Id, Constants.PropertyEditors.RadioButtonListAlias)
|
||||
{
|
||||
Name = "dt1"
|
||||
};
|
||||
repository.AddOrUpdate(dataType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//create a
|
||||
var dataType2 = (IDataTypeDefinition)new DataTypeDefinition(dataType.Id, Constants.PropertyEditors.RadioButtonListAlias)
|
||||
@@ -108,10 +108,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Name = "dt2"
|
||||
};
|
||||
repository.AddOrUpdate(dataType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.Move(dataType, container1).ToArray();
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(2, result.Count());
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var containerRepository = CreateContainerRepository(unitOfWork);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DataTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.That(container.Id, Is.GreaterThan(0));
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
@@ -152,11 +152,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var containerRepository = CreateContainerRepository(unitOfWork);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DataTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
containerRepository.Delete(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
Assert.IsNull(found);
|
||||
@@ -173,11 +173,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DataTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dataTypeDefinition = new DataTypeDefinition(container.Id, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" };
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(container.Id, dataTypeDefinition.ParentId);
|
||||
}
|
||||
@@ -193,15 +193,15 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var container = new EntityContainer(Constants.ObjectTypes.DataTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
IDataTypeDefinition dataType = new DataTypeDefinition(container.Id, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" };
|
||||
repository.AddOrUpdate(dataType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
containerRepository.Delete(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
Assert.IsNull(found);
|
||||
@@ -223,7 +223,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var id = dataTypeDefinition.Id;
|
||||
Assert.That(id, Is.GreaterThan(0));
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var exists = repository.Exists(dataTypeDefinition.Id);
|
||||
|
||||
// Assert
|
||||
@@ -374,14 +374,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
CreatorId = 0
|
||||
};
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var definition = repository.Get(dataTypeDefinition.Id);
|
||||
definition.Name = "AgeDataType Updated";
|
||||
definition.PropertyEditorAlias = "Test.TestEditor"; //change
|
||||
repository.AddOrUpdate(definition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var definitionUpdated = repository.Get(dataTypeDefinition.Id);
|
||||
|
||||
@@ -409,11 +409,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var existsBefore = repository.Exists(dataTypeDefinition.Id);
|
||||
|
||||
repository.Delete(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var existsAfter = repository.Exists(dataTypeDefinition.Id);
|
||||
|
||||
@@ -451,7 +451,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var dataTypeDefinition = new DataTypeDefinition(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" };
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var dtid = dataTypeDefinition.Id;
|
||||
|
||||
unitOfWork.Database.Insert(new DataTypePreValueDto { DataTypeNodeId = dtid, SortOrder = 0, Value = "test1"});
|
||||
@@ -471,7 +471,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var dataTypeDefinition = new DataTypeDefinition(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" };
|
||||
repository.AddOrUpdate(dataTypeDefinition);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var dtid = dataTypeDefinition.Id;
|
||||
|
||||
var id = unitOfWork.Database.Insert(new DataTypePreValueDto { DataTypeNodeId = dtid, SortOrder = 0, Value = "test1" });
|
||||
@@ -492,7 +492,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = Container.GetInstance<IDatabaseUnitOfWork, IDataTypeDefinitionRepository>(unitOfWork);
|
||||
dtd = new DataTypeDefinition(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" };
|
||||
repository.AddOrUpdate(dtd);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
unitOfWork.Database.Insert(new DataTypePreValueDto() { DataTypeNodeId = dtd.Id, SortOrder = 0, Value = "test1" });
|
||||
unitOfWork.Database.Insert(new DataTypePreValueDto() { DataTypeNodeId = dtd.Id, SortOrder = 1, Value = "test2" });
|
||||
@@ -523,7 +523,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = Container.GetInstance<IDatabaseUnitOfWork, IDataTypeDefinitionRepository>(unitOfWork);
|
||||
dtd = new DataTypeDefinition(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" };
|
||||
repository.AddOrUpdate(dtd);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
id = unitOfWork.Database.Insert(new DataTypePreValueDto() { DataTypeNodeId = dtd.Id, SortOrder = 0, Value = "test1" });
|
||||
unitOfWork.Database.Insert(new DataTypePreValueDto() { DataTypeNodeId = dtd.Id, SortOrder = 1, Value = "test2" });
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
|
||||
repository.AddOrUpdate(dictionaryItem);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
dictionaryItem = repository.Get("Testing1235");
|
||||
@@ -81,7 +81,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
|
||||
repository.AddOrUpdate(dictionaryItem);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
dictionaryItem = repository.Get(dictionaryItem.Key);
|
||||
@@ -113,7 +113,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
|
||||
repository.AddOrUpdate(dictionaryItem);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
dictionaryItem = repository.Get(dictionaryItem.Id);
|
||||
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var dictionaryItem = (IDictionaryItem) new DictionaryItem("Testing1235");
|
||||
|
||||
repository.AddOrUpdate(dictionaryItem);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
dictionaryItem = repository.Get(dictionaryItem.Id);
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(read);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(read.Id);
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
item.Translations = translations;
|
||||
|
||||
repository.AddOrUpdate(item);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dictionaryItem = repository.Get(1);
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
item.Translations = translations;
|
||||
|
||||
repository.AddOrUpdate(item);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dictionaryItem = (DictionaryItem)repository.Get(1);
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var item = repository.Get(1);
|
||||
repository.Delete(item);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(1);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
contentTypeRepo.AddOrUpdate(ct);
|
||||
var content = new Content("test", -1, ct) { CreatorId = 0, WriterId = 0 };
|
||||
contentRepo.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
return content.Id;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var domain = (IDomain)new UmbracoDomain("test.com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
domain = repo.Get(domain.Id);
|
||||
@@ -105,7 +105,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var domain = (IDomain)new UmbracoDomain("test.com") { RootContentId = content.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
domain = repo.Get(domain.Id);
|
||||
@@ -139,12 +139,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var domain1 = (IDomain)new UmbracoDomain("test.com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var domain2 = (IDomain)new UmbracoDomain("test.com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain2);
|
||||
|
||||
Assert.Throws<DuplicateNameException>(unitOfWork.Commit);
|
||||
Assert.Throws<DuplicateNameException>(unitOfWork.Flush);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var domain = (IDomain)new UmbracoDomain("test.com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
repo.Delete(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
domain = repo.Get(domain.Id);
|
||||
@@ -204,12 +204,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
langRepo.AddOrUpdate(lang2);
|
||||
var content2 = new Content("test", -1, ct) { CreatorId = 0, WriterId = 0 };
|
||||
contentRepo.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
|
||||
var domain = (IDomain)new UmbracoDomain("test.com") { RootContentId = content1.Id, LanguageId = lang1.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
domain = repo.Get(domain.Id);
|
||||
@@ -218,7 +218,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
domain.RootContentId = content2.Id;
|
||||
domain.LanguageId = lang2.Id;
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
domain = repo.Get(domain.Id);
|
||||
@@ -253,7 +253,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var domain = (IDomain)new UmbracoDomain("test" + i + ".com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var found = repo.Exists("test1.com");
|
||||
@@ -284,7 +284,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var domain = (IDomain)new UmbracoDomain("test" + i + ".com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var found = repo.GetByName("test1.com");
|
||||
@@ -315,7 +315,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var domain = (IDomain)new UmbracoDomain("test " + i + ".com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var all = repo.GetAll();
|
||||
@@ -347,7 +347,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var domain = (IDomain)new UmbracoDomain("test " + i + ".com") { RootContentId = content.Id, LanguageId = lang.Id };
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
ids.Add(domain.Id);
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
LanguageId = lang.Id
|
||||
};
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var all = repo.GetAll(false);
|
||||
@@ -417,7 +417,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var c = new Content("test" + i, -1, ct) { CreatorId = 0, WriterId = 0 };
|
||||
contentRepo.AddOrUpdate(c);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
contentItems.Add(c);
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
LanguageId = lang.Id
|
||||
};
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var all1 = repo.GetAssignedDomains(contentItems[0].Id, true);
|
||||
@@ -468,7 +468,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var c = new Content("test" + i, -1, ct) { CreatorId = 0, WriterId = 0 };
|
||||
contentRepo.AddOrUpdate(c);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
contentItems.Add(c);
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
LanguageId = lang.Id
|
||||
};
|
||||
repo.AddOrUpdate(domain);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var all1 = repo.GetAssignedDomains(contentItems[0].Id, false);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
CultureName = au.DisplayName
|
||||
};
|
||||
repository.AddOrUpdate(language);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
language = repository.GetByIsoCode(au.Name);
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
CultureName = au.DisplayName
|
||||
};
|
||||
repository.AddOrUpdate(language);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
language = repository.GetByCultureName(au.DisplayName);
|
||||
@@ -215,7 +215,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var languageBR = new Language("pt-BR") {CultureName = "pt-BR"};
|
||||
repository.AddOrUpdate(languageBR);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(languageBR.HasIdentity, Is.True);
|
||||
@@ -238,7 +238,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
language.CultureName = "pt-BR";
|
||||
|
||||
repository.AddOrUpdate(language);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var languageUpdated = repository.Get(5);
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var language = repository.Get(3);
|
||||
repository.Delete(language);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(3);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = new Macro("test1", "Test", "~/usercontrol/blah.ascx", "MyAssembly", "test.xslt", "~/views/macropartials/test.cshtml");
|
||||
repository.AddOrUpdate(macro);
|
||||
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Commit);
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Flush);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = repository.Get(1);
|
||||
macro.Alias = "test2";
|
||||
repository.AddOrUpdate(macro);
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Commit);
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Flush);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -172,7 +172,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = new Macro("test", "Test", "~/usercontrol/blah.ascx", "MyAssembly", "test.xslt", "~/views/macropartials/test.cshtml");
|
||||
macro.Properties.Add(new MacroProperty("test", "Test", 0, "test"));
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(macro.HasIdentity, Is.True);
|
||||
@@ -204,7 +204,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
macro.XsltPath = "";
|
||||
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var macroUpdated = repository.Get(2);
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = repository.Get(3);
|
||||
Assert.IsNotNull(macro);
|
||||
repository.Delete(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(3);
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(macro);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.Greater(macro.Properties.First().Id, 0); //ensure id is returned
|
||||
@@ -306,7 +306,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(macro);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var result = repository.Get(macro.Id);
|
||||
@@ -330,12 +330,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = new Macro("newmacro", "A new macro", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml");
|
||||
macro.Properties.Add(new MacroProperty("blah1", "New1", 4, "test.editor"));
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.Get(macro.Id);
|
||||
result.Properties.Remove("blah1");
|
||||
repository.AddOrUpdate(result);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
result = repository.Get(macro.Id);
|
||||
@@ -365,7 +365,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
macro.Properties.Add(prop2);
|
||||
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var result = repository.Get(macro.Id);
|
||||
@@ -388,13 +388,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = repository.Get(1);
|
||||
macro.Properties.Add(new MacroProperty("new1", "New1", 3, "test"));
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Act
|
||||
macro = repository.Get(1);
|
||||
macro.Properties["new1"].Name = "this is a new name";
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
|
||||
// Assert
|
||||
@@ -417,13 +417,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var macro = repository.Get(1);
|
||||
macro.Properties.Add(new MacroProperty("new1", "New1", 3, "test"));
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Act
|
||||
macro = repository.Get(1);
|
||||
macro.Properties.UpdateProperty("new1", newAlias: "newAlias");
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var result = repository.Get(1);
|
||||
@@ -447,7 +447,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml"));
|
||||
repository.AddOrUpdate(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "MyAssembly2", "test2.xslt", "~/views/macropartials/test2.cshtml"));
|
||||
repository.AddOrUpdate(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "MyAssembly3", "test3.xslt", "~/views/macropartials/test3.cshtml"));
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var image = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
repository.AddOrUpdate(image);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
|
||||
repository.AddOrUpdate(folder);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -125,7 +125,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
mediaTypeRepository.AddOrUpdate(mediaType);
|
||||
repository.AddOrUpdate(image);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(mediaType.HasIdentity, Is.True);
|
||||
@@ -148,11 +148,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(file);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var image = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
repository.AddOrUpdate(image);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(file.HasIdentity, Is.True);
|
||||
@@ -179,11 +179,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(file);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var image = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
repository.AddOrUpdate(image);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(file.HasIdentity, Is.True);
|
||||
@@ -228,7 +228,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var content = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
content.Name = "Test File Updated";
|
||||
repository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var updatedContent = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var media = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
repository.Delete(media);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var deleted = repository.Get(NodeDto.NodeIdSeed + 2);
|
||||
var exists = repository.Exists(NodeDto.NodeIdSeed + 2);
|
||||
|
||||
@@ -48,16 +48,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var container1 = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah1" };
|
||||
containerRepository.AddOrUpdate(container1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var container2 = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah2", ParentId = container1.Id };
|
||||
containerRepository.AddOrUpdate(container2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType = (IMediaType)MockedContentTypes.CreateVideoMediaType();
|
||||
contentType.ParentId = container2.Id;
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//create a
|
||||
var contentType2 = (IMediaType)new MediaType(contentType, "hello")
|
||||
@@ -66,10 +66,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
contentType.ParentId = contentType.Id;
|
||||
repository.AddOrUpdate(contentType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.Move(contentType, container1).ToArray();
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(2, result.Length);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var container = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.That(container.Id, Is.GreaterThan(0));
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
@@ -112,12 +112,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var container = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.That(container.Id, Is.GreaterThan(0));
|
||||
|
||||
// Act
|
||||
containerRepository.Delete(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
Assert.IsNull(found);
|
||||
@@ -135,12 +135,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var container = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType = MockedContentTypes.CreateVideoMediaType();
|
||||
contentType.ParentId = container.Id;
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(container.Id, contentType.ParentId);
|
||||
}
|
||||
@@ -157,16 +157,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var container = new EntityContainer(Constants.ObjectTypes.MediaTypeGuid) { Name = "blah" };
|
||||
containerRepository.AddOrUpdate(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
IMediaType contentType = MockedContentTypes.CreateVideoMediaType();
|
||||
contentType.ParentId = container.Id;
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
containerRepository.Delete(container);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = containerRepository.Get(container.Id);
|
||||
Assert.IsNull(found);
|
||||
@@ -189,7 +189,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var contentType = MockedContentTypes.CreateVideoMediaType();
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.HasIdentity, Is.True);
|
||||
@@ -212,7 +212,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var videoMediaType = MockedContentTypes.CreateVideoMediaType();
|
||||
repository.AddOrUpdate(videoMediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var mediaType = repository.Get(NodeDto.NodeIdSeed);
|
||||
@@ -227,7 +227,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
DataTypeDefinitionId = -88
|
||||
});
|
||||
repository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var dirty = ((MediaType) mediaType).IsDirty();
|
||||
|
||||
@@ -251,11 +251,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var mediaType = MockedContentTypes.CreateVideoMediaType();
|
||||
repository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType2 = repository.Get(mediaType.Id);
|
||||
repository.Delete(contentType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(mediaType.Id);
|
||||
|
||||
@@ -380,13 +380,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var mediaType = MockedContentTypes.CreateVideoMediaType();
|
||||
repository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var mediaTypeV2 = repository.Get(NodeDto.NodeIdSeed);
|
||||
mediaTypeV2.PropertyGroups["Media"].PropertyTypes.Remove("title");
|
||||
repository.AddOrUpdate(mediaTypeV2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var mediaTypeV3 = repository.Get(NodeDto.NodeIdSeed);
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var mediaType = MockedContentTypes.CreateVideoMediaType();
|
||||
repository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var contentType = repository.Get(NodeDto.NodeIdSeed);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var member = MockedMember.CreateSimpleMember(memberType1, "blah" + i, "blah" + i + "@example.com", "blah", "blah" + i);
|
||||
repository.AddOrUpdate(member);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -102,7 +102,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var member = MockedMember.CreateSimpleMember(memberType3, "b3lah" + i, "b3lah" + i + "@example.com", "b3lah", "b3lah" + i);
|
||||
repository.AddOrUpdate(member);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
@@ -243,11 +243,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberTypeRepository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var member = MockedMember.CreateSimpleMember(memberType, "Johnny Hefty", "johnny@example.com", "123", "hefty");
|
||||
repository.AddOrUpdate(member);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var sut = repository.Get(member.Id);
|
||||
|
||||
@@ -278,17 +278,17 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberTypeRepository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var member = MockedMember.CreateSimpleMember(memberType, "Johnny Hefty", "johnny@example.com", "123", "hefty");
|
||||
repository.AddOrUpdate(member);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
sut = repository.Get(member.Id);
|
||||
//when the password is null it will not overwrite what is already there.
|
||||
sut.RawPasswordValue = null;
|
||||
repository.AddOrUpdate(sut);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
sut = repository.Get(member.Id);
|
||||
|
||||
Assert.That(sut.RawPasswordValue, Is.EqualTo("123"));
|
||||
@@ -308,17 +308,17 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberTypeRepository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var member = MockedMember.CreateSimpleMember(memberType, "Johnny Hefty", "johnny@example.com", "123", "hefty");
|
||||
repository.AddOrUpdate(member);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
sut = repository.Get(member.Id);
|
||||
sut.Username = "This is new";
|
||||
sut.Email = "thisisnew@hello.com";
|
||||
repository.AddOrUpdate(sut);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
sut = repository.Get(member.Id);
|
||||
|
||||
Assert.That(sut.Email, Is.EqualTo("thisisnew@hello.com"));
|
||||
@@ -358,12 +358,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberTypeRepository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
var member = MockedMember.CreateSimpleMember(memberType, name ?? "Johnny Hefty", email ?? "johnny@example.com", password ?? "123", username ?? "hefty", key);
|
||||
repository.AddOrUpdate(member);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
return member;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType = MockedContentTypes.CreateSimpleMemberType(alias);
|
||||
memberTypeRepository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
return memberType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var sut = repository.Get(memberType.Id);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
memberType.Alias = null;
|
||||
repository.AddOrUpdate(memberType);
|
||||
|
||||
Assert.Throws<InvalidOperationException>(unitOfWork.Commit);
|
||||
Assert.Throws<InvalidOperationException>(unitOfWork.Flush);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType1 = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var memberType2 = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberType2.Name = "AnotherType";
|
||||
memberType2.Alias = "anotherType";
|
||||
repository.AddOrUpdate(memberType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.GetAll();
|
||||
|
||||
@@ -111,13 +111,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType1 = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var memberType2 = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberType2.Name = "AnotherType";
|
||||
memberType2.Alias = "anotherType";
|
||||
repository.AddOrUpdate(memberType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = ((IReadRepository<Guid, IMemberType>)repository).GetAll(memberType1.Key, memberType2.Key);
|
||||
|
||||
@@ -136,13 +136,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType1 = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var memberType2 = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberType2.Name = "AnotherType";
|
||||
memberType2.Alias = "anotherType";
|
||||
repository.AddOrUpdate(memberType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.Get(memberType1.Key);
|
||||
|
||||
@@ -165,14 +165,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var memberType1 = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberType1.PropertyTypeCollection.Clear();
|
||||
repository.AddOrUpdate(memberType1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var memberType2 = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberType2.PropertyTypeCollection.Clear();
|
||||
memberType2.Name = "AnotherType";
|
||||
memberType2.Alias = "anotherType";
|
||||
repository.AddOrUpdate(memberType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var result = repository.GetAll();
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
memberType = repository.Get(memberType.Id);
|
||||
Assert.That(memberType, Is.Not.Null);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
memberType = repository.Get(memberType.Key);
|
||||
Assert.That(memberType, Is.Not.Null);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
memberType = repository.Get(memberType.Id);
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
IMemberType memberType2 = MockedContentTypes.CreateSimpleMemberType("test2");
|
||||
repository.AddOrUpdate(memberType1);
|
||||
repository.AddOrUpdate(memberType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var m1Ids = memberType1.PropertyTypes.Select(x => x.Id).ToArray();
|
||||
var m2Ids = memberType2.PropertyTypes.Select(x => x.Id).ToArray();
|
||||
@@ -268,11 +268,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
repository.AddOrUpdate(memberType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var contentType2 = repository.Get(memberType.Id);
|
||||
repository.Delete(contentType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(memberType.Id);
|
||||
|
||||
|
||||
@@ -37,14 +37,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var partialView = new PartialView("test-path-1.cshtml") { Content = "// partialView" };
|
||||
repository.AddOrUpdate(partialView);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("test-path-1.cshtml"));
|
||||
Assert.AreEqual("test-path-1.cshtml", partialView.Path);
|
||||
Assert.AreEqual("/Views/Partials/test-path-1.cshtml", partialView.VirtualPath);
|
||||
|
||||
partialView = new PartialView("path-2/test-path-2.cshtml") { Content = "// partialView" };
|
||||
repository.AddOrUpdate(partialView);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.cshtml"));
|
||||
Assert.AreEqual("path-2\\test-path-2.cshtml", partialView.Path); // fixed in 7.3 - 7.2.8 does not update the path
|
||||
Assert.AreEqual("/Views/Partials/path-2/test-path-2.cshtml", partialView.VirtualPath);
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
partialView = new PartialView("path-2\\test-path-3.cshtml") { Content = "// partialView" };
|
||||
repository.AddOrUpdate(partialView);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.cshtml"));
|
||||
Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path);
|
||||
Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath);
|
||||
|
||||
@@ -39,10 +39,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
},
|
||||
});
|
||||
repo.AddOrUpdate(entry);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
repo.Delete(entry);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
entry = repo.Get(entry.Key);
|
||||
Assert.IsNull(entry);
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
},
|
||||
});
|
||||
repo.AddOrUpdate(entry);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = repo.GetAll().ToArray();
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
},
|
||||
});
|
||||
repo.AddOrUpdate(entry);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = repo.GetAll().ToArray();
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
},
|
||||
});
|
||||
repo.AddOrUpdate(entry);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
entry = repo.Get(entry.Key);
|
||||
@@ -163,7 +163,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
entry.Rules.First().RuleType = "asdf";
|
||||
repo.AddOrUpdate(entry);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
entry = repo.Get(entry.Key);
|
||||
@@ -192,7 +192,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
},
|
||||
});
|
||||
repo.AddOrUpdate(entry);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
entry = repo.Get(entry.Key);
|
||||
@@ -231,7 +231,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
});
|
||||
repo.AddOrUpdate(entry2);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = repo.GetAll().ToArray();
|
||||
Assert.AreEqual(2, found.Count());
|
||||
@@ -269,7 +269,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
});
|
||||
repo.AddOrUpdate(entry2);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = repo.GetAll(entry1.Key).ToArray();
|
||||
Assert.AreEqual(1, found.Count());
|
||||
@@ -296,7 +296,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var ct = MockedContentTypes.CreateBasicContentType("testing");
|
||||
ctRepo.AddOrUpdate(ct);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var result = new List<IContent>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
@@ -304,7 +304,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repo.AddOrUpdate(c);
|
||||
result.Add(c);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var relationType = repositoryType.Get(1);
|
||||
var relation = new Relation(NodeDto.NodeIdSeed + 2, NodeDto.NodeIdSeed + 3, relationType);
|
||||
repository.AddOrUpdate(relation);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(relation, Is.Not.Null);
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var relation = repository.Get(1);
|
||||
relation.Comment = "This relation has been updated";
|
||||
repository.AddOrUpdate(relation);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var relationUpdated = repository.Get(1);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var relation = repository.Get(2);
|
||||
repository.Delete(relation);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(2);
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
relationTypeRepository.AddOrUpdate(relateContent);
|
||||
relationTypeRepository.AddOrUpdate(relateContentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Create and Save ContentType "umbTextpage" -> (NodeDto.NodeIdSeed)
|
||||
ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
|
||||
@@ -293,7 +293,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var relation2 = new Relation(textpage.Id, subpage2.Id, relateContent) { Comment = string.Empty };
|
||||
relationRepository.AddOrUpdate(relation);
|
||||
relationRepository.AddOrUpdate(relation2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
"relateMemberToContent") { IsBidirectional = true, Name = "Relate Member to Content" };
|
||||
|
||||
repository.AddOrUpdate(relateMemberToContent);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(relateMemberToContent.HasIdentity, Is.True);
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
relationType.Alias = relationType.Alias + "Updated";
|
||||
relationType.Name = relationType.Name + " Updated";
|
||||
repository.AddOrUpdate(relationType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var relationTypeUpdated = repository.Get(3);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var relationType = repository.Get(3);
|
||||
repository.Delete(relationType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(3);
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(relateContent);//Id 2
|
||||
repository.AddOrUpdate(relateContentType);//Id 3
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var script = new Script("test-add-script.js") {Content = "/// <reference name=\"MicrosoftAjax.js\"/>"};
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(_fileSystem.FileExists("test-add-script.js"), Is.True);
|
||||
@@ -72,11 +72,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var script = new Script("test-updated-script.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
script.Content = "/// <reference name=\"MicrosoftAjax-Updated.js\"/>";
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var scriptUpdated = repository.Get("test-updated-script.js");
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var script = repository.Get("test-script.js");
|
||||
repository.Delete(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(script2);
|
||||
var script3 = new Script("test-script3.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
repository.AddOrUpdate(script3);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var scripts = repository.GetAll();
|
||||
@@ -161,7 +161,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(script2);
|
||||
var script3 = new Script("test-script3.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
repository.AddOrUpdate(script3);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var scripts = repository.GetAll("test-script1.js", "test-script2.js");
|
||||
@@ -200,13 +200,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var script = new Script("test-move-script.js") { Content = content };
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
script = repository.Get("test-move-script.js");
|
||||
script.Path = "moved/test-move-script.js";
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var existsOld = repository.Exists("test-move-script.js");
|
||||
var existsNew = repository.Exists("moved/test-move-script.js");
|
||||
@@ -231,14 +231,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var script = new Script("test-path-1.js") { Content = "// script" };
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("test-path-1.js"));
|
||||
Assert.AreEqual("test-path-1.js", script.Path);
|
||||
Assert.AreEqual("/scripts/test-path-1.js", script.VirtualPath);
|
||||
|
||||
script = new Script("path-2/test-path-2.js") { Content = "// script" };
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.js"));
|
||||
Assert.AreEqual("path-2\\test-path-2.js", script.Path); // fixed in 7.3 - 7.2.8 does not update the path
|
||||
Assert.AreEqual("/scripts/path-2/test-path-2.js", script.VirtualPath);
|
||||
@@ -250,7 +250,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
script = new Script("path-2\\test-path-3.js") { Content = "// script" };
|
||||
repository.AddOrUpdate(script);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.js"));
|
||||
Assert.AreEqual("path-2\\test-path-3.js", script.Path);
|
||||
Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.Now);
|
||||
repository.AddOrUpdate(server);
|
||||
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Commit);
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Flush);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var server = repository.Get(1);
|
||||
server.ServerIdentity = "COMPUTER2";
|
||||
repository.AddOrUpdate(server);
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Commit);
|
||||
Assert.Throws<SqlCeException>(unitOfWork.Flush);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -170,7 +170,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.Now);
|
||||
repository.AddOrUpdate(server);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(server.HasIdentity, Is.True);
|
||||
@@ -193,7 +193,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
server.IsActive = true;
|
||||
|
||||
repository.AddOrUpdate(server);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var serverUpdated = repository.Get(2);
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var server = repository.Get(3);
|
||||
Assert.IsNotNull(server);
|
||||
repository.Delete(server);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var exists = repository.Exists(3);
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(new ServerRegistration("http://localhost", "COMPUTER1", DateTime.Now) { IsActive = true });
|
||||
repository.AddOrUpdate(new ServerRegistration("http://www.mydomain.com", "COMPUTER2", DateTime.Now));
|
||||
repository.AddOrUpdate(new ServerRegistration("https://www.another.domain.com", "Computer3", DateTime.Now));
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var stylesheet = new Stylesheet("test-add.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(_fileSystem.FileExists("test-add.css"), Is.True);
|
||||
@@ -75,12 +75,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var stylesheetUpdate = repository.Get("test-update.css");
|
||||
stylesheetUpdate.Content = "body { color:#000; }";
|
||||
repository.AddOrUpdate(stylesheetUpdate);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var stylesheetUpdated = repository.Get("test-update.css");
|
||||
|
||||
@@ -102,12 +102,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
stylesheet.AddProperty(new StylesheetProperty("Test", "p", "font-size:2em;"));
|
||||
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
stylesheet = repository.Get(stylesheet.Name);
|
||||
@@ -132,7 +132,7 @@ p{font-size:2em;}"));
|
||||
// Act
|
||||
var stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
stylesheet.AddProperty(new StylesheetProperty("Test", "p", "font-size:2em;"));
|
||||
|
||||
@@ -152,10 +152,10 @@ p{font-size:2em;}"));
|
||||
// Act
|
||||
var stylesheet = new Stylesheet("test-delete.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
repository.Delete(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(_fileSystem.FileExists("test-delete.css"), Is.False);
|
||||
@@ -191,7 +191,7 @@ p{font-size:2em;}"));
|
||||
|
||||
var stylesheet = new Stylesheet("styles-v2.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var stylesheets = repository.GetAll();
|
||||
@@ -214,7 +214,7 @@ p{font-size:2em;}"));
|
||||
|
||||
var stylesheet = new Stylesheet("styles-v2.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var stylesheets = repository.GetAll("styles-v2.css", "styles.css");
|
||||
@@ -253,14 +253,14 @@ p{font-size:2em;}"));
|
||||
|
||||
var stylesheet = new Stylesheet("test-path-1.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("test-path-1.css"));
|
||||
Assert.AreEqual("test-path-1.css", stylesheet.Path);
|
||||
Assert.AreEqual("/css/test-path-1.css", stylesheet.VirtualPath);
|
||||
|
||||
stylesheet = new Stylesheet("path-2/test-path-2.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.css"));
|
||||
Assert.AreEqual("path-2\\test-path-2.css", stylesheet.Path); // fixed in 7.3 - 7.2.8 does not update the path
|
||||
Assert.AreEqual("/css/path-2/test-path-2.css", stylesheet.VirtualPath);
|
||||
@@ -272,7 +272,7 @@ p{font-size:2em;}"));
|
||||
|
||||
stylesheet = new Stylesheet("path-2\\test-path-3.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" };
|
||||
repository.AddOrUpdate(stylesheet);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.css"));
|
||||
Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path);
|
||||
Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath);
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(tag);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(tag.HasIdentity, Is.True);
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(tag);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var tag2 = new Tag()
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Text = "Test2"
|
||||
};
|
||||
repository.AddOrUpdate(tag2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(tag.HasIdentity, Is.True);
|
||||
@@ -110,10 +110,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -141,10 +141,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -181,10 +181,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -224,10 +224,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -265,10 +265,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -302,10 +302,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -347,12 +347,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -392,12 +392,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -438,12 +438,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -474,12 +474,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
var tags = new[]
|
||||
@@ -515,12 +515,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -560,10 +560,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -606,10 +606,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -651,10 +651,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -699,16 +699,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var mediaType = MockedContentTypes.CreateImageMediaType("image2");
|
||||
mediaTypeRepository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var media1 = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
mediaRepository.AddOrUpdate(media1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -758,16 +758,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var mediaType = MockedContentTypes.CreateImageMediaType("image2");
|
||||
mediaTypeRepository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var media1 = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
mediaRepository.AddOrUpdate(media1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -810,10 +810,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -829,7 +829,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
contentRepository.Delete(content1);
|
||||
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(0, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
@@ -851,22 +851,22 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var mediaType = MockedContentTypes.CreateImageMediaType("image2");
|
||||
mediaTypeRepository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var media1 = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
mediaRepository.AddOrUpdate(media1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
@@ -936,22 +936,22 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//create data to relate to
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("test", "Test");
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var content1 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var content2 = MockedContent.CreateSimpleContent(contentType);
|
||||
contentRepository.AddOrUpdate(content2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var mediaType = MockedContentTypes.CreateImageMediaType("image2");
|
||||
mediaTypeRepository.AddOrUpdate(mediaType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var media1 = MockedMedia.CreateMediaImage(mediaType, -1);
|
||||
mediaRepository.AddOrUpdate(media1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var repository = CreateRepository(unitOfWork);
|
||||
repository.AssignTagsToProperty(
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
OwnerUserId = 0
|
||||
};
|
||||
repo.AddOrUpdate(task);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
repo.Delete(task);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
task = repo.Get(task.Id);
|
||||
Assert.IsNull(task);
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
EntityId = -1,
|
||||
OwnerUserId = 0
|
||||
});
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var found = repo.GetAll().ToArray();
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
|
||||
repo.AddOrUpdate(task);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
task = repo.Get(task.Id);
|
||||
@@ -101,7 +101,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
task.Closed = true;
|
||||
|
||||
repo.AddOrUpdate(task);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
task = repo.Get(task.Id);
|
||||
@@ -129,7 +129,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
};
|
||||
|
||||
repo.AddOrUpdate(task);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//re-get
|
||||
task = repo.Get(task.Id);
|
||||
@@ -218,7 +218,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
EntityId = entityId,
|
||||
OwnerUserId = 0
|
||||
});
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
OwnerUserId = 0
|
||||
};
|
||||
repo.AddOrUpdate(task);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var alltasktypes = taskTypeRepo.GetAll();
|
||||
|
||||
taskTypeRepo.Delete(taskType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(alltasktypes.Count() - 1, taskTypeRepo.GetAll().Count());
|
||||
Assert.AreEqual(0, repo.GetAll().Count());
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = @"<%@ Master Language=""C#"" %>"
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test"), Is.Not.Null);
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var template = new Template("test", "test");
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test"), Is.Not.Null);
|
||||
@@ -121,13 +121,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//NOTE: This has to be persisted first
|
||||
var template = new Template("test", "test");
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var template2 = new Template("test2", "test2");
|
||||
template2.SetMasterTemplate(template);
|
||||
repository.AddOrUpdate(template2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test2"), Is.Not.Null);
|
||||
@@ -151,7 +151,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var template = new Template("test", "test");
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test"), Is.Not.Null);
|
||||
@@ -175,7 +175,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test"), Is.Not.Null);
|
||||
@@ -199,13 +199,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//NOTE: This has to be persisted first
|
||||
var template = new Template("test", "test");
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var template2 = new Template("test2", "test2");
|
||||
template2.SetMasterTemplate(template);
|
||||
repository.AddOrUpdate(template2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test2"), Is.Not.Null);
|
||||
@@ -231,14 +231,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var template2 = new Template("test", "test")
|
||||
{
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("test1", template2.Alias);
|
||||
@@ -261,18 +261,18 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var template2 = new Template("test1", "test1")
|
||||
{
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
template.Alias = "test1";
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("test11", template.Alias);
|
||||
@@ -297,11 +297,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = @"<%@ Master Language=""C#"" %>"
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
template.Content = @"<%@ Master Language=""VB"" %>";
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var updated = repository.Get("test");
|
||||
|
||||
@@ -328,11 +328,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
template.Content += "<html></html>";
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var updated = repository.Get("test");
|
||||
|
||||
@@ -356,13 +356,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = @"<%@ Master Language=""C#"" %>"
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var templates = repository.Get("test");
|
||||
Assert.That(_masterPageFileSystem.FileExists("test.master"), Is.True);
|
||||
repository.Delete(templates);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(repository.Get("test"));
|
||||
@@ -384,13 +384,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = ViewHelper.GetDefaultFileContent()
|
||||
};
|
||||
repository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var templates = repository.Get("test");
|
||||
Assert.That(_viewsFileSystem.FileExists("test.cshtml"), Is.True);
|
||||
repository.Delete(templates);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(repository.Get("test"));
|
||||
@@ -415,7 +415,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var textpage = MockedContent.CreateSimpleContent(contentType);
|
||||
contentTypeRepository.AddOrUpdate(contentType);
|
||||
contentRepo.AddOrUpdate(textpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
|
||||
var template = new Template("test", "test")
|
||||
@@ -423,16 +423,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Content = @"<%@ Master Language=""C#"" %>"
|
||||
};
|
||||
templateRepository.AddOrUpdate(template);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
textpage.Template = template;
|
||||
contentRepo.AddOrUpdate(textpage);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var templates = templateRepository.Get("test");
|
||||
templateRepository.Delete(templates);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(templateRepository.Get("test"));
|
||||
@@ -467,12 +467,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(parent);
|
||||
repository.AddOrUpdate(child);
|
||||
repository.AddOrUpdate(baby);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var templates = repository.Get("parent");
|
||||
repository.Delete(templates);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(repository.Get("test"));
|
||||
@@ -651,7 +651,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(toddler4);
|
||||
repository.AddOrUpdate(baby1);
|
||||
repository.AddOrUpdate(baby2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(string.Format("-1,{0}", parent.Id), parent.Path);
|
||||
@@ -696,12 +696,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(child2);
|
||||
repository.AddOrUpdate(toddler1);
|
||||
repository.AddOrUpdate(toddler2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Act
|
||||
toddler2.SetMasterTemplate(child2);
|
||||
repository.AddOrUpdate(toddler2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(string.Format("-1,{0},{1},{2}", parent.Id, child2.Id, toddler2.Id), toddler2.Path);
|
||||
@@ -814,7 +814,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(toddler4);
|
||||
repository.AddOrUpdate(baby1);
|
||||
repository.AddOrUpdate(baby2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
return new[] {parent, child1, child2, toddler1, toddler2, toddler3, toddler4, baby1, baby2};
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(user);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(user.HasIdentity, Is.True);
|
||||
@@ -76,9 +76,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(user1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
repository.AddOrUpdate(use2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(user1.HasIdentity, Is.True);
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var user = MockedUser.CreateUser(CreateAndCommitUserType());
|
||||
repository.AddOrUpdate(user);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var resolved = repository.Get((int)user.Id);
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var user = MockedUser.CreateUser(CreateAndCommitUserType());
|
||||
repository.AddOrUpdate(user);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var resolved = (User)repository.Get((int)user.Id);
|
||||
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
resolved.RemoveAllowedSection("content");
|
||||
|
||||
repository.AddOrUpdate(resolved);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var updatedItem = (User)repository.Get((int)user.Id);
|
||||
|
||||
// Assert
|
||||
@@ -174,14 +174,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(user);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var id = user.Id;
|
||||
|
||||
var utRepo = new UserTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Logger, MappingResolver);
|
||||
var repository2 = new UserRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Logger, utRepo, MappingResolver);
|
||||
|
||||
repository2.Delete(user);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var resolved = repository2.Get((int) id);
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var user = MockedUser.CreateUser(CreateAndCommitUserType());
|
||||
repository.AddOrUpdate(user);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var updatedItem = repository.Get((int) user.Id);
|
||||
@@ -373,7 +373,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(users[0]);
|
||||
repository.AddOrUpdate(users[1]);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var result = repository.GetAll((int) users[0].Id, (int) users[1].Id).ToArray();
|
||||
@@ -411,7 +411,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
repository.AddOrUpdate(users[0]);
|
||||
repository.AddOrUpdate(users[1]);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var result = repository.GetAll((int) users[0].Id, (int) users[1].Id, (int) users[2].Id).ToArray();
|
||||
@@ -447,7 +447,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
users[0].AddAllowedSection("settings");
|
||||
|
||||
repository.AddOrUpdate(users[0]);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
var result = repository.Get((int) users[0].Id);
|
||||
@@ -474,7 +474,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(user1);
|
||||
repository.AddOrUpdate(user2);
|
||||
repository.AddOrUpdate(user3);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
|
||||
@@ -501,7 +501,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var user1 = MockedUser.CreateUser(CreateAndCommitUserType(), "1", "test", "media");
|
||||
repository.AddOrUpdate(user1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(3, user1.DefaultPermissions.Count());
|
||||
@@ -537,7 +537,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(user1);
|
||||
repository.AddOrUpdate(user2);
|
||||
repository.AddOrUpdate(user3);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
return new IUser[] { user1, user2, user3 };
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = new UserTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Logger, MappingResolver);
|
||||
var userType = MockedUserType.CreateUserType();
|
||||
repository.AddOrUpdate(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
return userType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(userType.HasIdentity, Is.True);
|
||||
@@ -69,9 +69,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(userType1);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
repository.AddOrUpdate(userType2);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Assert
|
||||
Assert.That(userType1.HasIdentity, Is.True);
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var userType = MockedUserType.CreateUserType();
|
||||
repository.AddOrUpdate(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var resolved = repository.Get(userType.Id);
|
||||
@@ -112,14 +112,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var userType = MockedUserType.CreateUserType();
|
||||
repository.AddOrUpdate(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var resolved = repository.Get(userType.Id);
|
||||
resolved.Name = "New Name";
|
||||
resolved.Permissions = new[]{"Z", "Y", "X"};
|
||||
repository.AddOrUpdate(resolved);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var updatedItem = repository.Get(userType.Id);
|
||||
|
||||
// Assert
|
||||
@@ -142,12 +142,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
var id = userType.Id;
|
||||
|
||||
var repository2 = new UserTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Logger, MappingResolver);
|
||||
repository2.Delete(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
var resolved = repository2.Get(id);
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var userType = MockedUserType.CreateUserType();
|
||||
repository.AddOrUpdate(userType);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
|
||||
// Act
|
||||
var resolved = repository.Get(userType.Id);
|
||||
@@ -291,7 +291,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(userType1);
|
||||
repository.AddOrUpdate(userType2);
|
||||
repository.AddOrUpdate(userType3);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
return new IUserType[] {userType1, userType2, userType3};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1351,7 +1351,7 @@ namespace Umbraco.Tests.Services
|
||||
foreach (var content in list)
|
||||
{
|
||||
repository.AddOrUpdate(content.Value);
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
|
||||
Assert.That(c.Value.HasIdentity, Is.True);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Tests.Services
|
||||
repository.AddOrUpdate(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml"));
|
||||
repository.AddOrUpdate(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "MyAssembly2", "test2.xslt", "~/views/macropartials/test2.cshtml"));
|
||||
repository.AddOrUpdate(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "MyAssembly3", "test3.xslt", "~/views/macropartials/test3.cshtml"));
|
||||
unitOfWork.Commit();
|
||||
unitOfWork.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user