diff --git a/Backend/MonitorPanel/MonitorPanel.API/MonitorPanel.API.csproj b/Backend/MonitorPanel/MonitorPanel.API/MonitorPanel.API.csproj index 223e972..b3d87aa 100644 --- a/Backend/MonitorPanel/MonitorPanel.API/MonitorPanel.API.csproj +++ b/Backend/MonitorPanel/MonitorPanel.API/MonitorPanel.API.csproj @@ -8,11 +8,16 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/Backend/MonitorPanel/MonitorPanel.API/Program.cs b/Backend/MonitorPanel/MonitorPanel.API/Program.cs index 1b05030..26f147d 100644 --- a/Backend/MonitorPanel/MonitorPanel.API/Program.cs +++ b/Backend/MonitorPanel/MonitorPanel.API/Program.cs @@ -1,3 +1,8 @@ +using Microsoft.EntityFrameworkCore; +using MonitorPanel.Core.Abstractions; +using MonitorPanel.DataAccess; +using MonitorPanel.DataAccess.Repositories; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -8,6 +13,11 @@ builder.Services.AddOpenApi(); builder.Services.AddSwaggerGen(); +builder.Services.AddDbContext(options => + options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))); + +builder.Services.AddScoped(); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/Backend/MonitorPanel/MonitorPanel.Core/Abstractions/IServersRepository.cs b/Backend/MonitorPanel/MonitorPanel.Core/Abstractions/IServersRepository.cs new file mode 100644 index 0000000..62864f9 --- /dev/null +++ b/Backend/MonitorPanel/MonitorPanel.Core/Abstractions/IServersRepository.cs @@ -0,0 +1,11 @@ +using MonitorPanel.Core.Models; +namespace MonitorPanel.Core.Abstractions; + +public interface IServersRepository +{ + Task> GetAllServersAsync(); + Task GetServerByIdAsync(Guid id); + Task AddServerAsync(Server server); + Task UpdateServerAsync(Guid id, Server server); + Task DeleteServerAsync(Guid id); +} \ No newline at end of file diff --git a/Backend/MonitorPanel/MonitorPanel.DataAccess/Entities/ServerEntity.cs b/Backend/MonitorPanel/MonitorPanel.DataAccess/Entities/ServerEntity.cs new file mode 100644 index 0000000..cb41b54 --- /dev/null +++ b/Backend/MonitorPanel/MonitorPanel.DataAccess/Entities/ServerEntity.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +namespace MonitorPanel.DataAccess.Entities; + +public class ServerEntity +{ + public Guid Id { get; set; } + public string Name { get; set; } = null!; + public bool IsHttps { get; set; } + [Required] + public string Address { get; set; } = null!; + string? Path { get; set; } + [Required] + public int Port { get; set; } +} \ No newline at end of file diff --git a/Backend/MonitorPanel/MonitorPanel.DataAccess/MonitorPanel.DataAccess.csproj b/Backend/MonitorPanel/MonitorPanel.DataAccess/MonitorPanel.DataAccess.csproj new file mode 100644 index 0000000..ca21264 --- /dev/null +++ b/Backend/MonitorPanel/MonitorPanel.DataAccess/MonitorPanel.DataAccess.csproj @@ -0,0 +1,26 @@ + + + + net10.0 + enable + enable + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/Backend/MonitorPanel/MonitorPanel.DataAccess/MonitorPanelDbContext.cs b/Backend/MonitorPanel/MonitorPanel.DataAccess/MonitorPanelDbContext.cs new file mode 100644 index 0000000..f08a9ac --- /dev/null +++ b/Backend/MonitorPanel/MonitorPanel.DataAccess/MonitorPanelDbContext.cs @@ -0,0 +1,8 @@ +using Microsoft.EntityFrameworkCore; +using MonitorPanel.DataAccess.Entities; +namespace MonitorPanel.DataAccess; + +public class MonitorPanelDbContext(DbContextOptions options) : DbContext(options) +{ + public DbSet Servers => Set(); +} diff --git a/Backend/MonitorPanel/MonitorPanel.DataAccess/Repositories/ServersRepository.cs b/Backend/MonitorPanel/MonitorPanel.DataAccess/Repositories/ServersRepository.cs new file mode 100644 index 0000000..fca2f78 --- /dev/null +++ b/Backend/MonitorPanel/MonitorPanel.DataAccess/Repositories/ServersRepository.cs @@ -0,0 +1,31 @@ +using MonitorPanel.Core.Abstractions; +using MonitorPanel.Core.Models; +namespace MonitorPanel.DataAccess.Repositories; + +public class ServersRepository : IServersRepository +{ + public Task AddServerAsync(Server server) + { + throw new NotImplementedException(); + } + + public Task DeleteServerAsync(Guid id) + { + throw new NotImplementedException(); + } + + public Task> GetAllServersAsync() + { + throw new NotImplementedException(); + } + + public Task GetServerByIdAsync(Guid id) + { + throw new NotImplementedException(); + } + + public Task UpdateServerAsync(Guid id, Server server) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Backend/MonitorPanel/MonitorPanel.slnx b/Backend/MonitorPanel/MonitorPanel.slnx index d433a4e..eacb59b 100644 --- a/Backend/MonitorPanel/MonitorPanel.slnx +++ b/Backend/MonitorPanel/MonitorPanel.slnx @@ -1,4 +1,5 @@ +