From 8d95d2ae3d98aaae16c9ea873731895448000950 Mon Sep 17 00:00:00 2001 From: adm Date: Thu, 14 Nov 2024 09:23:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console_ui/Program.cs | 2 + console_ui/console_ui.csproj | 20 +++++ data/DAO/Group.cs | 9 ++ data/DAO/User.cs | 16 ++++ .../20241111142428_InitialCreate.Designer.cs | 83 +++++++++++++++++++ .../20241111142428_InitialCreate.cs | 63 ++++++++++++++ .../RemoteDatabaseContextModelSnapshot.cs | 80 ++++++++++++++++++ data/RemoteDatabaseContext.cs | 32 +++++++ data/data.csproj | 18 ++++ domain/Class1.cs | 6 ++ domain/domain.csproj | 13 +++ presnce.sln | 40 +++++++++ ui/Class1.cs | 6 ++ ui/ui.csproj | 13 +++ 14 files changed, 401 insertions(+) create mode 100644 console_ui/Program.cs create mode 100644 console_ui/console_ui.csproj create mode 100644 data/DAO/Group.cs create mode 100644 data/DAO/User.cs create mode 100644 data/Migrations/20241111142428_InitialCreate.Designer.cs create mode 100644 data/Migrations/20241111142428_InitialCreate.cs create mode 100644 data/Migrations/RemoteDatabaseContextModelSnapshot.cs create mode 100644 data/RemoteDatabaseContext.cs create mode 100644 data/data.csproj create mode 100644 domain/Class1.cs create mode 100644 domain/domain.csproj create mode 100644 presnce.sln create mode 100644 ui/Class1.cs create mode 100644 ui/ui.csproj diff --git a/console_ui/Program.cs b/console_ui/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/console_ui/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/console_ui/console_ui.csproj b/console_ui/console_ui.csproj new file mode 100644 index 0000000..883c822 --- /dev/null +++ b/console_ui/console_ui.csproj @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + Exe + net8.0 + enable + enable + + + diff --git a/data/DAO/Group.cs b/data/DAO/Group.cs new file mode 100644 index 0000000..1a778f6 --- /dev/null +++ b/data/DAO/Group.cs @@ -0,0 +1,9 @@ +namespace data.DAO; + +public class GroupDAO +{ + public int Id { get; set; } + public string Name { get; set; } + public virtual IEnumerable Users { get; set; } + +} diff --git a/data/DAO/User.cs b/data/DAO/User.cs new file mode 100644 index 0000000..385afa6 --- /dev/null +++ b/data/DAO/User.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace data.DAO +{ + public class UserDAO + { + public Guid Guid { get; set; } + public string Name { get; set; } + public virtual GroupDAO Group { get; set; } + + } +} diff --git a/data/Migrations/20241111142428_InitialCreate.Designer.cs b/data/Migrations/20241111142428_InitialCreate.Designer.cs new file mode 100644 index 0000000..06dac4b --- /dev/null +++ b/data/Migrations/20241111142428_InitialCreate.Designer.cs @@ -0,0 +1,83 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using data; + +#nullable disable + +namespace data.Migrations +{ + [DbContext(typeof(RemoteDatabaseContext))] + [Migration("20241111142428_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("data.DAO.GroupDAO", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("groups"); + }); + + modelBuilder.Entity("data.DAO.UserDAO", b => + { + b.Property("Guid") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Guid"); + + b.HasIndex("GroupId"); + + b.ToTable("users"); + }); + + modelBuilder.Entity("data.DAO.UserDAO", b => + { + b.HasOne("data.DAO.GroupDAO", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("data.DAO.GroupDAO", b => + { + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/data/Migrations/20241111142428_InitialCreate.cs b/data/Migrations/20241111142428_InitialCreate.cs new file mode 100644 index 0000000..d14854e --- /dev/null +++ b/data/Migrations/20241111142428_InitialCreate.cs @@ -0,0 +1,63 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace data.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "groups", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "users", + columns: table => new + { + Guid = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + GroupId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_users", x => x.Guid); + table.ForeignKey( + name: "FK_users_groups_GroupId", + column: x => x.GroupId, + principalTable: "groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_users_GroupId", + table: "users", + column: "GroupId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "users"); + + migrationBuilder.DropTable( + name: "groups"); + } + } +} diff --git a/data/Migrations/RemoteDatabaseContextModelSnapshot.cs b/data/Migrations/RemoteDatabaseContextModelSnapshot.cs new file mode 100644 index 0000000..c5848d9 --- /dev/null +++ b/data/Migrations/RemoteDatabaseContextModelSnapshot.cs @@ -0,0 +1,80 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using data; + +#nullable disable + +namespace data.Migrations +{ + [DbContext(typeof(RemoteDatabaseContext))] + partial class RemoteDatabaseContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("data.DAO.GroupDAO", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("groups"); + }); + + modelBuilder.Entity("data.DAO.UserDAO", b => + { + b.Property("Guid") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Guid"); + + b.HasIndex("GroupId"); + + b.ToTable("users"); + }); + + modelBuilder.Entity("data.DAO.UserDAO", b => + { + b.HasOne("data.DAO.GroupDAO", "Group") + .WithMany("Users") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("data.DAO.GroupDAO", b => + { + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/data/RemoteDatabaseContext.cs b/data/RemoteDatabaseContext.cs new file mode 100644 index 0000000..1347e32 --- /dev/null +++ b/data/RemoteDatabaseContext.cs @@ -0,0 +1,32 @@ +using data.DAO; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace data +{ + public class RemoteDatabaseContext: DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Password=123;Username=postgres;Database=presence"); + } + + DbSet groups { get;set;} + + DbSet users { get;set;} + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(it => it.Guid); + modelBuilder.Entity().HasKey(it => it.Id); + + modelBuilder.Entity().Property(it => it.Guid).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.Id).ValueGeneratedOnAdd(); + } + + } +} diff --git a/data/data.csproj b/data/data.csproj new file mode 100644 index 0000000..2b2ccad --- /dev/null +++ b/data/data.csproj @@ -0,0 +1,18 @@ + + + + net8.0 + enable + enable + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + diff --git a/domain/Class1.cs b/domain/Class1.cs new file mode 100644 index 0000000..21c3090 --- /dev/null +++ b/domain/Class1.cs @@ -0,0 +1,6 @@ +namespace domain; + +public class Class1 +{ + +} diff --git a/domain/domain.csproj b/domain/domain.csproj new file mode 100644 index 0000000..8d40d4a --- /dev/null +++ b/domain/domain.csproj @@ -0,0 +1,13 @@ + + + + + + + + net8.0 + enable + enable + + + diff --git a/presnce.sln b/presnce.sln new file mode 100644 index 0000000..5c98574 --- /dev/null +++ b/presnce.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "data", "data\data.csproj", "{FFE39EC0-DDC4-4670-A991-075ADF2B4C95}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domain", "domain\domain.csproj", "{633650E7-0BAB-49D7-B72A-64A5D5A22E26}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ui", "ui\ui.csproj", "{2CDB8D72-14C6-47D8-9DA0-852E72FE1663}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "console_ui", "console_ui\console_ui.csproj", "{1DEBFFB8-8F9B-4E2D-881C-A65AE0A206C3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FFE39EC0-DDC4-4670-A991-075ADF2B4C95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFE39EC0-DDC4-4670-A991-075ADF2B4C95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFE39EC0-DDC4-4670-A991-075ADF2B4C95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFE39EC0-DDC4-4670-A991-075ADF2B4C95}.Release|Any CPU.Build.0 = Release|Any CPU + {633650E7-0BAB-49D7-B72A-64A5D5A22E26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {633650E7-0BAB-49D7-B72A-64A5D5A22E26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {633650E7-0BAB-49D7-B72A-64A5D5A22E26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {633650E7-0BAB-49D7-B72A-64A5D5A22E26}.Release|Any CPU.Build.0 = Release|Any CPU + {2CDB8D72-14C6-47D8-9DA0-852E72FE1663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CDB8D72-14C6-47D8-9DA0-852E72FE1663}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CDB8D72-14C6-47D8-9DA0-852E72FE1663}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CDB8D72-14C6-47D8-9DA0-852E72FE1663}.Release|Any CPU.Build.0 = Release|Any CPU + {1DEBFFB8-8F9B-4E2D-881C-A65AE0A206C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DEBFFB8-8F9B-4E2D-881C-A65AE0A206C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DEBFFB8-8F9B-4E2D-881C-A65AE0A206C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DEBFFB8-8F9B-4E2D-881C-A65AE0A206C3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ui/Class1.cs b/ui/Class1.cs new file mode 100644 index 0000000..de5442b --- /dev/null +++ b/ui/Class1.cs @@ -0,0 +1,6 @@ +namespace ui; + +public class Class1 +{ + +} diff --git a/ui/ui.csproj b/ui/ui.csproj new file mode 100644 index 0000000..dcf787d --- /dev/null +++ b/ui/ui.csproj @@ -0,0 +1,13 @@ + + + + + + + + net8.0 + enable + enable + + +