add column with migrations

This commit is contained in:
Userok 2024-11-15 16:11:22 +03:00
parent 7fe7ce1b3d
commit 460e0eb28a
18 changed files with 930 additions and 31 deletions

11
console_ui/Program.cs Normal file
View File

@ -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}");
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\presence\presence.csproj"/>
</ItemGroup>
</Project>

View File

@ -6,12 +6,17 @@ using System.Threading.Tasks;
namespace presence.DAO namespace presence.DAO
{ {
internal class Attedances public class Attedances
{ {
public int AttedanceId { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public int IdSubjectGroup { get; set; } public int SubjectGroupId { get; set; }
public int IdStudents { get; set; } public virtual GroupSubject SubjectGroup { get; set; }
public int IdGroup { get; set; } public int StudentsId { get; set; }
public int IdVisit { 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; }
} }
} }

View File

@ -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; }
}
}

View File

@ -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
{
}
}

View File

@ -6,7 +6,9 @@ using System.Threading.Tasks;
namespace presence.DAO namespace presence.DAO
{ {
internal class Group public class Groups
{ {
public int IdGroup { get; set; }
public string NameGroup { get; set; }
} }
} }

View File

@ -6,9 +6,9 @@ using System.Threading.Tasks;
namespace presence.DAO 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 StartTime { get; set; }
public DateTime EndTime { get; set; } public DateTime EndTime { get; set; }
} }

View File

@ -6,7 +6,15 @@ using System.Threading.Tasks;
namespace presence.DAO 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; }
} }
} }

View File

@ -6,7 +6,9 @@ using System.Threading.Tasks;
namespace presence.DAO namespace presence.DAO
{ {
internal class Subjects public class Subjects
{ {
public int IdSubject { get; set; }
public string NameSubject { get; set; }
} }
} }

View File

@ -6,9 +6,9 @@ using System.Threading.Tasks;
namespace presence.DAO namespace presence.DAO
{ {
internal class Visit public class Visits
{ {
public int IdVisit { get; set; } public int VisitId { get; set; }
public string NameVisit { get; set; } public string NameVisit { get; set; }
} }
} }

View File

@ -0,0 +1,267 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("AttedanceId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AttedanceId"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<int>("StudentsId")
.HasColumnType("integer");
b.Property<int>("SubjectGroupId")
.HasColumnType("integer");
b.Property<int>("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<int>("GroupSubjectId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GroupSubjectId"));
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<int>("SemesterId")
.HasColumnType("integer");
b.Property<int>("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<int>("IdGroup")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("IdGroup"));
b.Property<string>("NameGroup")
.IsRequired()
.HasColumnType("text");
b.HasKey("IdGroup");
b.ToTable("groups");
});
modelBuilder.Entity("presence.DAO.Semesters", b =>
{
b.Property<int>("SemesterId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SemesterId"));
b.Property<DateTime>("EndTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("StartTime")
.HasColumnType("timestamp with time zone");
b.HasKey("SemesterId");
b.ToTable("Semesters");
});
modelBuilder.Entity("presence.DAO.Students", b =>
{
b.Property<int>("StudentId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("StudentId"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("StudentId");
b.HasIndex("GroupId");
b.ToTable("students");
});
modelBuilder.Entity("presence.DAO.Subjects", b =>
{
b.Property<int>("IdSubject")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("IdSubject"));
b.Property<string>("NameSubject")
.IsRequired()
.HasColumnType("text");
b.HasKey("IdSubject");
b.ToTable("Subjects");
});
modelBuilder.Entity("presence.DAO.Visits", b =>
{
b.Property<int>("VisitId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("VisitId"));
b.Property<string>("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
}
}
}

View File

@ -0,0 +1,230 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace presence.Migrations
{
/// <inheritdoc />
public partial class columsupdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "groups",
columns: table => new
{
IdGroup = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
NameGroup = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_groups", x => x.IdGroup);
});
migrationBuilder.CreateTable(
name: "Semesters",
columns: table => new
{
SemesterId = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StartTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EndTime = table.Column<DateTime>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
NameSubject = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Subjects", x => x.IdSubject);
});
migrationBuilder.CreateTable(
name: "Visits",
columns: table => new
{
VisitId = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
NameVisit = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Visits", x => x.VisitId);
});
migrationBuilder.CreateTable(
name: "students",
columns: table => new
{
StudentId = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
FirstName = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
GroupId = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
SubjectId = table.Column<int>(type: "integer", nullable: false),
GroupId = table.Column<int>(type: "integer", nullable: false),
SemesterId = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
SubjectGroupId = table.Column<int>(type: "integer", nullable: false),
StudentsId = table.Column<int>(type: "integer", nullable: false),
GroupId = table.Column<int>(type: "integer", nullable: false),
VisitId = table.Column<int>(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");
}
/// <inheritdoc />
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");
}
}
}

View File

@ -0,0 +1,264 @@
// <auto-generated />
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<int>("AttedanceId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("AttedanceId"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<int>("StudentsId")
.HasColumnType("integer");
b.Property<int>("SubjectGroupId")
.HasColumnType("integer");
b.Property<int>("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<int>("GroupSubjectId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("GroupSubjectId"));
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<int>("SemesterId")
.HasColumnType("integer");
b.Property<int>("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<int>("IdGroup")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("IdGroup"));
b.Property<string>("NameGroup")
.IsRequired()
.HasColumnType("text");
b.HasKey("IdGroup");
b.ToTable("groups");
});
modelBuilder.Entity("presence.DAO.Semesters", b =>
{
b.Property<int>("SemesterId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SemesterId"));
b.Property<DateTime>("EndTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("StartTime")
.HasColumnType("timestamp with time zone");
b.HasKey("SemesterId");
b.ToTable("Semesters");
});
modelBuilder.Entity("presence.DAO.Students", b =>
{
b.Property<int>("StudentId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("StudentId"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("StudentId");
b.HasIndex("GroupId");
b.ToTable("students");
});
modelBuilder.Entity("presence.DAO.Subjects", b =>
{
b.Property<int>("IdSubject")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("IdSubject"));
b.Property<string>("NameSubject")
.IsRequired()
.HasColumnType("text");
b.HasKey("IdSubject");
b.ToTable("Subjects");
});
modelBuilder.Entity("presence.DAO.Visits", b =>
{
b.Property<int>("VisitId")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("VisitId"));
b.Property<string>("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
}
}
}

View File

@ -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> groups { get; set; }
public DbSet<Students> students { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Students>().HasKey(it => it.StudentId);
modelBuilder.Entity<Groups>().HasKey(it => it.IdGroup);
modelBuilder.Entity<GroupSubject>().HasKey(it => it.GroupSubjectId);
modelBuilder.Entity<Semesters>().HasKey(it => it.SemesterId);
modelBuilder.Entity<Visits>().HasKey(it => it.VisitId);
modelBuilder.Entity<Subjects>().HasKey(it => it.IdSubject);
modelBuilder.Entity<Attedances>().HasKey(it => it.AttedanceId);
modelBuilder.Entity<Students>().Property(it => it.StudentId).ValueGeneratedOnAdd();
modelBuilder.Entity<Groups>().Property(it => it.IdGroup).ValueGeneratedOnAdd();
modelBuilder.Entity<GroupSubject>().Property(it => it.GroupSubjectId).ValueGeneratedOnAdd();
modelBuilder.Entity<Semesters>().Property(it => it.SemesterId).ValueGeneratedOnAdd();
modelBuilder.Entity<Visits>().Property(it => it.VisitId).ValueGeneratedOnAdd();
modelBuilder.Entity<Subjects>().Property(it => it.IdSubject).ValueGeneratedOnAdd();
modelBuilder.Entity<Attedances>().Property(it => it.AttedanceId).ValueGeneratedOnAdd();
}
}
}

View File

@ -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<Groups> GetAllGroup();
public bool AddGroup(Groups group);
}
}

View File

@ -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<Groups> GetAllGroup()
{
return _dbContext.groups.ToList();
}
}
}

View File

@ -6,18 +6,18 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="DAO\Visits.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="DAO\" />
</ItemGroup>
</Project> </Project>

View File

@ -1,10 +1,12 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.12.35506.116 d17.12 VisualStudioVersion = 17.12.35506.116
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presence", "presence\presence.csproj", "{5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presence", "presence\presence.csproj", "{5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "console_ui", "console_ui\console_ui.csproj", "{F7E55888-B021-45E4-8D75-312353FFE5E8}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{5DBB1FC4-E89F-4AC4-B5FD-D8A5321300CA}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE