diff --git a/console_ui/Program.cs b/console_ui/Program.cs new file mode 100644 index 0000000..064cf8d --- /dev/null +++ b/console_ui/Program.cs @@ -0,0 +1,11 @@ +using presence; +using presence.Repository; +RemoteDatabaseContext remoteDatabaseContext = new RemoteDatabaseContext(); +SQLGroupRepository groupRepository = new SQLGroupRepository(remoteDatabaseContext); + + + +foreach (var item in groupRepository.GetAllGroup()) +{ + Console.WriteLine($"{item.IdGroup} {item.NameGroup}"); +} \ No newline at end of file diff --git a/console_ui/console_ui.csproj b/console_ui/console_ui.csproj new file mode 100644 index 0000000..6a63661 --- /dev/null +++ b/console_ui/console_ui.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/presence/DAO/Attedances.cs b/presence/DAO/Attedances.cs index a1e7ab3..7ee48e2 100644 --- a/presence/DAO/Attedances.cs +++ b/presence/DAO/Attedances.cs @@ -6,12 +6,17 @@ using System.Threading.Tasks; namespace presence.DAO { - internal class Attedances + public class Attedances { + public int AttedanceId { get; set; } public DateTime Date { get; set; } - public int IdSubjectGroup { get; set; } - public int IdStudents { get; set; } - public int IdGroup { get; set; } - public int IdVisit { get; set; } + public int SubjectGroupId { get; set; } + public virtual GroupSubject SubjectGroup { get; set; } + public int StudentsId { get; set; } + public virtual Students Student { get; set; } + public int GroupId { get; set; } + public virtual Groups Group { get; set; } + public int VisitId { get; set; } + public virtual Visits Visit { get; set; } } } diff --git a/presence/DAO/GroupSubject.cs b/presence/DAO/GroupSubject.cs new file mode 100644 index 0000000..fccbba5 --- /dev/null +++ b/presence/DAO/GroupSubject.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace presence.DAO +{ + public class GroupSubject + { + public int GroupSubjectId { get; set; } + public int SubjectId { get; set; } + public virtual Subjects Subject { get; set; } + public int GroupId { get; set; } + public virtual Groups Group { get; set; } + public int SemesterId { get; set; } + public virtual Semesters Semester { get; set; } + } +} diff --git a/presence/DAO/GroupSubjest.cs b/presence/DAO/GroupSubjest.cs deleted file mode 100644 index 89dd7f8..0000000 --- a/presence/DAO/GroupSubjest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace presence.DAO -{ - internal class GroupSubjest - { - } -} diff --git a/presence/DAO/Groups.cs b/presence/DAO/Groups.cs index 1723846..17490e4 100644 --- a/presence/DAO/Groups.cs +++ b/presence/DAO/Groups.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; namespace presence.DAO { - internal class Group + public class Groups { + public int IdGroup { get; set; } + public string NameGroup { get; set; } } } diff --git a/presence/DAO/Semesters.cs b/presence/DAO/Semesters.cs index d4fcad6..e9d6027 100644 --- a/presence/DAO/Semesters.cs +++ b/presence/DAO/Semesters.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace presence.DAO { - internal class Semesters + public class Semesters { - public int IdSemester { get; set; } + public int SemesterId { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } } diff --git a/presence/DAO/Students.cs b/presence/DAO/Students.cs index 4f8c9c1..d4ab262 100644 --- a/presence/DAO/Students.cs +++ b/presence/DAO/Students.cs @@ -6,7 +6,15 @@ using System.Threading.Tasks; namespace presence.DAO { - internal class Students + public class Students { + public int StudentId { get; set; } + public string FirstName { get; set; } + + public string LastName { get; set; } + public string Surname { get; set; } + + public int GroupId { get; set; } + public virtual Groups Group { get; set; } } } diff --git a/presence/DAO/Subjects.cs b/presence/DAO/Subjects.cs index 04e3e9c..fee90bf 100644 --- a/presence/DAO/Subjects.cs +++ b/presence/DAO/Subjects.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; namespace presence.DAO { - internal class Subjects + public class Subjects { + public int IdSubject { get; set; } + public string NameSubject { get; set; } } } diff --git a/presence/DAO/Visits.cs b/presence/DAO/Visits.cs index cf2d474..d0d9c6c 100644 --- a/presence/DAO/Visits.cs +++ b/presence/DAO/Visits.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace presence.DAO { - internal class Visit + public class Visits { - public int IdVisit { get; set; } + public int VisitId { get; set; } public string NameVisit { get; set; } } } diff --git a/presence/Migrations/20241115130616_columsupdate.Designer.cs b/presence/Migrations/20241115130616_columsupdate.Designer.cs new file mode 100644 index 0000000..dd178f9 --- /dev/null +++ b/presence/Migrations/20241115130616_columsupdate.Designer.cs @@ -0,0 +1,267 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using presence; + +#nullable disable + +namespace presence.Migrations +{ + [DbContext(typeof(RemoteDatabaseContext))] + [Migration("20241115130616_columsupdate")] + partial class columsupdate + { + /// + 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("presence.DAO.Attedances", b => + { + b.Property("AttedanceId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttedanceId")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("StudentsId") + .HasColumnType("integer"); + + b.Property("SubjectGroupId") + .HasColumnType("integer"); + + b.Property("VisitId") + .HasColumnType("integer"); + + b.HasKey("AttedanceId"); + + b.HasIndex("GroupId"); + + b.HasIndex("StudentsId"); + + b.HasIndex("SubjectGroupId"); + + b.HasIndex("VisitId"); + + b.ToTable("Attedances"); + }); + + modelBuilder.Entity("presence.DAO.GroupSubject", b => + { + b.Property("GroupSubjectId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GroupSubjectId")); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("SemesterId") + .HasColumnType("integer"); + + b.Property("SubjectId") + .HasColumnType("integer"); + + b.HasKey("GroupSubjectId"); + + b.HasIndex("GroupId"); + + b.HasIndex("SemesterId"); + + b.HasIndex("SubjectId"); + + b.ToTable("GroupSubject"); + }); + + modelBuilder.Entity("presence.DAO.Groups", b => + { + b.Property("IdGroup") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("IdGroup")); + + b.Property("NameGroup") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("IdGroup"); + + b.ToTable("groups"); + }); + + modelBuilder.Entity("presence.DAO.Semesters", b => + { + b.Property("SemesterId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SemesterId")); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("SemesterId"); + + b.ToTable("Semesters"); + }); + + modelBuilder.Entity("presence.DAO.Students", b => + { + b.Property("StudentId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("StudentId")); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("StudentId"); + + b.HasIndex("GroupId"); + + b.ToTable("students"); + }); + + modelBuilder.Entity("presence.DAO.Subjects", b => + { + b.Property("IdSubject") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("IdSubject")); + + b.Property("NameSubject") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("IdSubject"); + + b.ToTable("Subjects"); + }); + + modelBuilder.Entity("presence.DAO.Visits", b => + { + b.Property("VisitId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VisitId")); + + b.Property("NameVisit") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("VisitId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("presence.DAO.Attedances", b => + { + b.HasOne("presence.DAO.Groups", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Students", "Student") + .WithMany() + .HasForeignKey("StudentsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.GroupSubject", "SubjectGroup") + .WithMany() + .HasForeignKey("SubjectGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Visits", "Visit") + .WithMany() + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Student"); + + b.Navigation("SubjectGroup"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("presence.DAO.GroupSubject", b => + { + b.HasOne("presence.DAO.Groups", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Semesters", "Semester") + .WithMany() + .HasForeignKey("SemesterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Subjects", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Semester"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("presence.DAO.Students", b => + { + b.HasOne("presence.DAO.Groups", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/presence/Migrations/20241115130616_columsupdate.cs b/presence/Migrations/20241115130616_columsupdate.cs new file mode 100644 index 0000000..5f1ad00 --- /dev/null +++ b/presence/Migrations/20241115130616_columsupdate.cs @@ -0,0 +1,230 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace presence.Migrations +{ + /// + public partial class columsupdate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "groups", + columns: table => new + { + IdGroup = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NameGroup = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_groups", x => x.IdGroup); + }); + + migrationBuilder.CreateTable( + name: "Semesters", + columns: table => new + { + SemesterId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StartTime = table.Column(type: "timestamp with time zone", nullable: false), + EndTime = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Semesters", x => x.SemesterId); + }); + + migrationBuilder.CreateTable( + name: "Subjects", + columns: table => new + { + IdSubject = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NameSubject = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Subjects", x => x.IdSubject); + }); + + migrationBuilder.CreateTable( + name: "Visits", + columns: table => new + { + VisitId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NameVisit = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Visits", x => x.VisitId); + }); + + migrationBuilder.CreateTable( + name: "students", + columns: table => new + { + StudentId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + Surname = table.Column(type: "text", nullable: false), + GroupId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_students", x => x.StudentId); + table.ForeignKey( + name: "FK_students_groups_GroupId", + column: x => x.GroupId, + principalTable: "groups", + principalColumn: "IdGroup", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupSubject", + columns: table => new + { + GroupSubjectId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SubjectId = table.Column(type: "integer", nullable: false), + GroupId = table.Column(type: "integer", nullable: false), + SemesterId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupSubject", x => x.GroupSubjectId); + table.ForeignKey( + name: "FK_GroupSubject_Semesters_SemesterId", + column: x => x.SemesterId, + principalTable: "Semesters", + principalColumn: "SemesterId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupSubject_Subjects_SubjectId", + column: x => x.SubjectId, + principalTable: "Subjects", + principalColumn: "IdSubject", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupSubject_groups_GroupId", + column: x => x.GroupId, + principalTable: "groups", + principalColumn: "IdGroup", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Attedances", + columns: table => new + { + AttedanceId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Date = table.Column(type: "timestamp with time zone", nullable: false), + SubjectGroupId = table.Column(type: "integer", nullable: false), + StudentsId = table.Column(type: "integer", nullable: false), + GroupId = table.Column(type: "integer", nullable: false), + VisitId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Attedances", x => x.AttedanceId); + table.ForeignKey( + name: "FK_Attedances_GroupSubject_SubjectGroupId", + column: x => x.SubjectGroupId, + principalTable: "GroupSubject", + principalColumn: "GroupSubjectId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Attedances_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "VisitId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Attedances_groups_GroupId", + column: x => x.GroupId, + principalTable: "groups", + principalColumn: "IdGroup", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Attedances_students_StudentsId", + column: x => x.StudentsId, + principalTable: "students", + principalColumn: "StudentId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Attedances_GroupId", + table: "Attedances", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_Attedances_StudentsId", + table: "Attedances", + column: "StudentsId"); + + migrationBuilder.CreateIndex( + name: "IX_Attedances_SubjectGroupId", + table: "Attedances", + column: "SubjectGroupId"); + + migrationBuilder.CreateIndex( + name: "IX_Attedances_VisitId", + table: "Attedances", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupSubject_GroupId", + table: "GroupSubject", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupSubject_SemesterId", + table: "GroupSubject", + column: "SemesterId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupSubject_SubjectId", + table: "GroupSubject", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_students_GroupId", + table: "students", + column: "GroupId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Attedances"); + + migrationBuilder.DropTable( + name: "GroupSubject"); + + migrationBuilder.DropTable( + name: "Visits"); + + migrationBuilder.DropTable( + name: "students"); + + migrationBuilder.DropTable( + name: "Semesters"); + + migrationBuilder.DropTable( + name: "Subjects"); + + migrationBuilder.DropTable( + name: "groups"); + } + } +} diff --git a/presence/Migrations/RemoteDatabaseContextModelSnapshot.cs b/presence/Migrations/RemoteDatabaseContextModelSnapshot.cs new file mode 100644 index 0000000..77debfb --- /dev/null +++ b/presence/Migrations/RemoteDatabaseContextModelSnapshot.cs @@ -0,0 +1,264 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using presence; + +#nullable disable + +namespace presence.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("presence.DAO.Attedances", b => + { + b.Property("AttedanceId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AttedanceId")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("StudentsId") + .HasColumnType("integer"); + + b.Property("SubjectGroupId") + .HasColumnType("integer"); + + b.Property("VisitId") + .HasColumnType("integer"); + + b.HasKey("AttedanceId"); + + b.HasIndex("GroupId"); + + b.HasIndex("StudentsId"); + + b.HasIndex("SubjectGroupId"); + + b.HasIndex("VisitId"); + + b.ToTable("Attedances"); + }); + + modelBuilder.Entity("presence.DAO.GroupSubject", b => + { + b.Property("GroupSubjectId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("GroupSubjectId")); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("SemesterId") + .HasColumnType("integer"); + + b.Property("SubjectId") + .HasColumnType("integer"); + + b.HasKey("GroupSubjectId"); + + b.HasIndex("GroupId"); + + b.HasIndex("SemesterId"); + + b.HasIndex("SubjectId"); + + b.ToTable("GroupSubject"); + }); + + modelBuilder.Entity("presence.DAO.Groups", b => + { + b.Property("IdGroup") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("IdGroup")); + + b.Property("NameGroup") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("IdGroup"); + + b.ToTable("groups"); + }); + + modelBuilder.Entity("presence.DAO.Semesters", b => + { + b.Property("SemesterId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("SemesterId")); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("SemesterId"); + + b.ToTable("Semesters"); + }); + + modelBuilder.Entity("presence.DAO.Students", b => + { + b.Property("StudentId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("StudentId")); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("StudentId"); + + b.HasIndex("GroupId"); + + b.ToTable("students"); + }); + + modelBuilder.Entity("presence.DAO.Subjects", b => + { + b.Property("IdSubject") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("IdSubject")); + + b.Property("NameSubject") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("IdSubject"); + + b.ToTable("Subjects"); + }); + + modelBuilder.Entity("presence.DAO.Visits", b => + { + b.Property("VisitId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("VisitId")); + + b.Property("NameVisit") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("VisitId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("presence.DAO.Attedances", b => + { + b.HasOne("presence.DAO.Groups", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Students", "Student") + .WithMany() + .HasForeignKey("StudentsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.GroupSubject", "SubjectGroup") + .WithMany() + .HasForeignKey("SubjectGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Visits", "Visit") + .WithMany() + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Student"); + + b.Navigation("SubjectGroup"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("presence.DAO.GroupSubject", b => + { + b.HasOne("presence.DAO.Groups", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Semesters", "Semester") + .WithMany() + .HasForeignKey("SemesterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("presence.DAO.Subjects", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Semester"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("presence.DAO.Students", b => + { + b.HasOne("presence.DAO.Groups", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/presence/RemoteDatabaseContext.cs b/presence/RemoteDatabaseContext.cs new file mode 100644 index 0000000..9a2a2cc --- /dev/null +++ b/presence/RemoteDatabaseContext.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore; +using presence.DAO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace presence +{ + public class RemoteDatabaseContext: DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseNpgsql("Host=45.67.56.214; Port=5454; Username=user22; Password=ruts0qI5; Database=user22;"); + } + + public DbSet groups { get; set; } + + public DbSet students { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(it => it.StudentId); + modelBuilder.Entity().HasKey(it => it.IdGroup); + modelBuilder.Entity().HasKey(it => it.GroupSubjectId); + modelBuilder.Entity().HasKey(it => it.SemesterId); + modelBuilder.Entity().HasKey(it => it.VisitId); + modelBuilder.Entity().HasKey(it => it.IdSubject); + modelBuilder.Entity().HasKey(it => it.AttedanceId); + + + modelBuilder.Entity().Property(it => it.StudentId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.IdGroup).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.GroupSubjectId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.SemesterId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.VisitId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.IdSubject).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(it => it.AttedanceId).ValueGeneratedOnAdd(); + } + } +} diff --git a/presence/Repository/IRepositoryGroup.cs b/presence/Repository/IRepositoryGroup.cs new file mode 100644 index 0000000..9fb7236 --- /dev/null +++ b/presence/Repository/IRepositoryGroup.cs @@ -0,0 +1,15 @@ +using presence.DAO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace presence.Repository +{ + public interface IRepositoryGroup + { + public IEnumerable GetAllGroup(); + public bool AddGroup(Groups group); + } +} diff --git a/presence/Repository/SQLGroupRepository.cs b/presence/Repository/SQLGroupRepository.cs new file mode 100644 index 0000000..ff86418 --- /dev/null +++ b/presence/Repository/SQLGroupRepository.cs @@ -0,0 +1,26 @@ +using presence.DAO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace presence.Repository +{ + public class SQLGroupRepository : IRepositoryGroup + + { + private readonly RemoteDatabaseContext _dbContext; + public SQLGroupRepository(RemoteDatabaseContext remoteDatabaseContext) { _dbContext = remoteDatabaseContext; } + + public bool AddGroup(Groups group) + { + throw new NotImplementedException(); + } + + public IEnumerable GetAllGroup() + { + return _dbContext.groups.ToList(); + } + } +} diff --git a/presence/presence.csproj b/presence/presence.csproj index e4cdd76..d5f33e7 100644 --- a/presence/presence.csproj +++ b/presence/presence.csproj @@ -6,18 +6,18 @@ enable + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/presence.sln b/presenceAndrianov.sln similarity index 64% rename from presence.sln rename to presenceAndrianov.sln index 34ad780..3af01be 100644 --- a/presence.sln +++ b/presenceAndrianov.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.12.35506.116 d17.12 +VisualStudioVersion = 17.12.35506.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presence", "presence\presence.csproj", "{5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "console_ui", "console_ui\console_ui.csproj", "{F7E55888-B021-45E4-8D75-312353FFE5E8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}.Release|Any CPU.Build.0 = Release|Any CPU + {F7E55888-B021-45E4-8D75-312353FFE5E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7E55888-B021-45E4-8D75-312353FFE5E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7E55888-B021-45E4-8D75-312353FFE5E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7E55888-B021-45E4-8D75-312353FFE5E8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE