server registration now static
This commit is contained in:
@@ -1,34 +1,34 @@
|
|||||||
using Umbraco.Core.Models;
|
using Umbraco.Core.Models;
|
||||||
using Umbraco.Core.Persistence.Dtos;
|
using Umbraco.Core.Persistence.Dtos;
|
||||||
|
|
||||||
namespace Umbraco.Core.Persistence.Factories
|
namespace Umbraco.Core.Persistence.Factories
|
||||||
{
|
{
|
||||||
internal class ServerRegistrationFactory
|
internal static class ServerRegistrationFactory
|
||||||
{
|
{
|
||||||
public ServerRegistration BuildEntity(ServerRegistrationDto dto)
|
public static ServerRegistration BuildEntity(ServerRegistrationDto dto)
|
||||||
{
|
{
|
||||||
var model = new ServerRegistration(dto.Id, dto.ServerAddress, dto.ServerIdentity, dto.DateRegistered, dto.DateAccessed, dto.IsActive, dto.IsMaster);
|
var model = new ServerRegistration(dto.Id, dto.ServerAddress, dto.ServerIdentity, dto.DateRegistered, dto.DateAccessed, dto.IsActive, dto.IsMaster);
|
||||||
// reset dirty initial properties (U4-1946)
|
// reset dirty initial properties (U4-1946)
|
||||||
model.ResetDirtyProperties(false);
|
model.ResetDirtyProperties(false);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerRegistrationDto BuildDto(IServerRegistration entity)
|
public static ServerRegistrationDto BuildDto(IServerRegistration entity)
|
||||||
{
|
{
|
||||||
var dto = new ServerRegistrationDto
|
var dto = new ServerRegistrationDto
|
||||||
{
|
{
|
||||||
ServerAddress = entity.ServerAddress,
|
ServerAddress = entity.ServerAddress,
|
||||||
DateRegistered = entity.CreateDate,
|
DateRegistered = entity.CreateDate,
|
||||||
IsActive = entity.IsActive,
|
IsActive = entity.IsActive,
|
||||||
IsMaster = ((ServerRegistration) entity).IsMaster,
|
IsMaster = ((ServerRegistration) entity).IsMaster,
|
||||||
DateAccessed = entity.UpdateDate,
|
DateAccessed = entity.UpdateDate,
|
||||||
ServerIdentity = entity.ServerIdentity
|
ServerIdentity = entity.ServerIdentity
|
||||||
};
|
};
|
||||||
|
|
||||||
if (entity.HasIdentity)
|
if (entity.HasIdentity)
|
||||||
dto.Id = entity.Id;
|
dto.Id = entity.Id;
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
|||||||
|
|
||||||
protected override IEnumerable<IServerRegistration> PerformGetAll(params int[] ids)
|
protected override IEnumerable<IServerRegistration> PerformGetAll(params int[] ids)
|
||||||
{
|
{
|
||||||
var factory = new ServerRegistrationFactory();
|
|
||||||
return Database.Fetch<ServerRegistrationDto>("WHERE id > 0")
|
return Database.Fetch<ServerRegistrationDto>("WHERE id > 0")
|
||||||
.Select(x => factory.BuildEntity(x));
|
.Select(x => ServerRegistrationFactory.BuildEntity(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<IServerRegistration> PerformGetByQuery(IQuery<IServerRegistration> query)
|
protected override IEnumerable<IServerRegistration> PerformGetByQuery(IQuery<IServerRegistration> query)
|
||||||
@@ -100,8 +99,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
|||||||
{
|
{
|
||||||
((ServerRegistration)entity).AddingEntity();
|
((ServerRegistration)entity).AddingEntity();
|
||||||
|
|
||||||
var factory = new ServerRegistrationFactory();
|
var dto = ServerRegistrationFactory.BuildDto(entity);
|
||||||
var dto = factory.BuildDto(entity);
|
|
||||||
|
|
||||||
var id = Convert.ToInt32(Database.Insert(dto));
|
var id = Convert.ToInt32(Database.Insert(dto));
|
||||||
entity.Id = id;
|
entity.Id = id;
|
||||||
@@ -112,9 +110,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
|||||||
protected override void PersistUpdatedItem(IServerRegistration entity)
|
protected override void PersistUpdatedItem(IServerRegistration entity)
|
||||||
{
|
{
|
||||||
((ServerRegistration)entity).UpdatingEntity();
|
((ServerRegistration)entity).UpdatingEntity();
|
||||||
|
|
||||||
var factory = new ServerRegistrationFactory();
|
var dto = ServerRegistrationFactory.BuildDto(entity);
|
||||||
var dto = factory.BuildDto(entity);
|
|
||||||
|
|
||||||
Database.Update(dto);
|
Database.Update(dto);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user