Creating the service interfaces and their implementations. Registering them in CoreInitialComposer. These services delegate the work to repositories

This commit is contained in:
elitsa
2020-02-18 14:48:36 +01:00
parent 166c04b1b6
commit b2ddc4a2b0
5 changed files with 70 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Strings;
using Umbraco.Core.Sync;
using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator;
@@ -129,6 +130,10 @@ namespace Umbraco.Core.Runtime
// by default, register a noop rebuilder
composition.RegisterUnique<IPublishedSnapshotRebuilder, PublishedSnapshotRebuilder>();
// will be injected in controllers when needed to invoke rest endpoints on Our
composition.RegisterUnique<IInstallationService, InstallationService>();
composition.RegisterUnique<IUpgradeService, UpgradeService>();
}
}
}

View File

@@ -0,0 +1,10 @@
using System.Threading.Tasks;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
public interface IInstallationService
{
Task Install(InstallLog installLog);
}
}

View File

@@ -0,0 +1,11 @@
using System.Threading.Tasks;
using Semver;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
public interface IUpgradeService
{
Task<UpgradeResult> CheckUpgrade(SemVersion version);
}
}

View File

@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
namespace Umbraco.Core.Services.Implement
{
public class InstallationService : IInstallationService
{
private readonly IInstallationRepository _installationRepository;
public InstallationService(IInstallationRepository installationRepository)
{
_installationRepository = installationRepository;
}
public async Task Install(InstallLog installLog)
{
await _installationRepository.SaveInstall(installLog);
}
}
}

View File

@@ -0,0 +1,23 @@
using System.Threading.Tasks;
using Semver;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Services;
namespace Umbraco.Core
{
internal class UpgradeService : IUpgradeService
{
private readonly IUpgradeCheckRepository _upgradeCheckRepository;
public UpgradeService(IUpgradeCheckRepository upgradeCheckRepository)
{
_upgradeCheckRepository = upgradeCheckRepository;
}
public async Task<UpgradeResult> CheckUpgrade(SemVersion version)
{
return await _upgradeCheckRepository.CheckUpgrade(version);
}
}
}