From d1a806545d9f5e746a204a82aadca7b33db76149 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Tue, 28 May 2024 07:01:23 +0300 Subject: [PATCH] feat: add maintenance mode --- .../IMaintenanceModeNotConfigureService.cs | 8 ++++++++ .../Common/Interfaces/IMaintenanceModeService.cs | 10 ++++++++++ .../Services/MaintenanceModeNotConfigureService.cs | 11 +++++++++++ Endpoint/Common/Services/MaintenanceModeService.cs | 14 ++++++++++++++ Endpoint/Program.cs | 2 ++ 5 files changed, 45 insertions(+) create mode 100644 Endpoint/Common/Interfaces/IMaintenanceModeNotConfigureService.cs create mode 100644 Endpoint/Common/Interfaces/IMaintenanceModeService.cs create mode 100644 Endpoint/Common/Services/MaintenanceModeNotConfigureService.cs create mode 100644 Endpoint/Common/Services/MaintenanceModeService.cs diff --git a/Endpoint/Common/Interfaces/IMaintenanceModeNotConfigureService.cs b/Endpoint/Common/Interfaces/IMaintenanceModeNotConfigureService.cs new file mode 100644 index 0000000..e2e6a5d --- /dev/null +++ b/Endpoint/Common/Interfaces/IMaintenanceModeNotConfigureService.cs @@ -0,0 +1,8 @@ +namespace Mirea.Api.Endpoint.Common.Interfaces; + +public interface IMaintenanceModeNotConfigureService +{ + bool IsMaintenanceMode { get; } + + void DisableMaintenanceMode(); +} \ No newline at end of file diff --git a/Endpoint/Common/Interfaces/IMaintenanceModeService.cs b/Endpoint/Common/Interfaces/IMaintenanceModeService.cs new file mode 100644 index 0000000..7f2d7cb --- /dev/null +++ b/Endpoint/Common/Interfaces/IMaintenanceModeService.cs @@ -0,0 +1,10 @@ +namespace Mirea.Api.Endpoint.Common.Interfaces; + +public interface IMaintenanceModeService +{ + bool IsMaintenanceMode { get; } + + void EnableMaintenanceMode(); + + void DisableMaintenanceMode(); +} \ No newline at end of file diff --git a/Endpoint/Common/Services/MaintenanceModeNotConfigureService.cs b/Endpoint/Common/Services/MaintenanceModeNotConfigureService.cs new file mode 100644 index 0000000..b11516b --- /dev/null +++ b/Endpoint/Common/Services/MaintenanceModeNotConfigureService.cs @@ -0,0 +1,11 @@ +using Mirea.Api.Endpoint.Common.Interfaces; + +namespace Mirea.Api.Endpoint.Common.Services; + +public class MaintenanceModeNotConfigureService : IMaintenanceModeNotConfigureService +{ + public bool IsMaintenanceMode { get; private set; } = true; + + public void DisableMaintenanceMode() => + IsMaintenanceMode = false; +} \ No newline at end of file diff --git a/Endpoint/Common/Services/MaintenanceModeService.cs b/Endpoint/Common/Services/MaintenanceModeService.cs new file mode 100644 index 0000000..a967fd1 --- /dev/null +++ b/Endpoint/Common/Services/MaintenanceModeService.cs @@ -0,0 +1,14 @@ +using Mirea.Api.Endpoint.Common.Interfaces; + +namespace Mirea.Api.Endpoint.Common.Services; + +public class MaintenanceModeService : IMaintenanceModeService +{ + public bool IsMaintenanceMode { get; private set; }; + + public void EnableMaintenanceMode() => + IsMaintenanceMode = true; + + public void DisableMaintenanceMode() => + IsMaintenanceMode = false; +} \ No newline at end of file diff --git a/Endpoint/Program.cs b/Endpoint/Program.cs index 4d79328..a238bbf 100644 --- a/Endpoint/Program.cs +++ b/Endpoint/Program.cs @@ -51,6 +51,8 @@ public class Program builder.Services.AddPersistence(builder.Configuration.Get()?.DbSettings?.ConnectionStringSql ?? string.Empty); builder.Services.AddControllers(); + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddCors(options => {