From 41dc907c539291f9615beb76cfc80bc07739e117 Mon Sep 17 00:00:00 2001 From: MaxKarme <91691525+MaxKarme@users.noreply.github.com> Date: Sun, 2 Apr 2023 17:39:42 +0400 Subject: [PATCH] add modelas and implements files --- .../Implements/ActivityStorage.cs | 12 +++++++++ .../Implements/DisciplineStorage.cs | 12 +++++++++ .../Implements/ExaminationResultStorage.cs | 12 +++++++++ .../Implements/ReportTypeStorage.cs | 12 +++++++++ .../Implements/StatementStorage.cs | 12 +++++++++ .../Implements/StudentStorage.cs | 12 +++++++++ .../DatabaseImplement/Models/Activity.cs | 19 +++++++++++++ .../DatabaseImplement/Models/Discipline.cs | 21 +++++++++++++++ .../Models/ExaminationResult.cs | 23 ++++++++++++++++ .../DatabaseImplement/Models/ReportType.cs | 19 +++++++++++++ .../Models/ReportTypeActivity.cs | 16 +++++++++++ .../Models/ReportTypeDiscipline.cs | 15 +++++++++++ .../DatabaseImplement/Models/Statement.cs | 21 +++++++++++++++ .../Models/StatementStudent.cs | 15 +++++++++++ .../DatabaseImplement/Models/Student.cs | 21 +++++++++++++++ .../Models/StudentExaminationResult.cs | 15 +++++++++++ .../DatabaseImplement/UniversityDatabase.cs | 27 +++++++++++++++++++ .../UniversityDatabaseImplement.csproj | 24 +++++++++++++++++ University/University.sln | 10 +++++-- 19 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 University/DatabaseImplement/Implements/ActivityStorage.cs create mode 100644 University/DatabaseImplement/Implements/DisciplineStorage.cs create mode 100644 University/DatabaseImplement/Implements/ExaminationResultStorage.cs create mode 100644 University/DatabaseImplement/Implements/ReportTypeStorage.cs create mode 100644 University/DatabaseImplement/Implements/StatementStorage.cs create mode 100644 University/DatabaseImplement/Implements/StudentStorage.cs create mode 100644 University/DatabaseImplement/Models/Activity.cs create mode 100644 University/DatabaseImplement/Models/Discipline.cs create mode 100644 University/DatabaseImplement/Models/ExaminationResult.cs create mode 100644 University/DatabaseImplement/Models/ReportType.cs create mode 100644 University/DatabaseImplement/Models/ReportTypeActivity.cs create mode 100644 University/DatabaseImplement/Models/ReportTypeDiscipline.cs create mode 100644 University/DatabaseImplement/Models/Statement.cs create mode 100644 University/DatabaseImplement/Models/StatementStudent.cs create mode 100644 University/DatabaseImplement/Models/Student.cs create mode 100644 University/DatabaseImplement/Models/StudentExaminationResult.cs create mode 100644 University/DatabaseImplement/UniversityDatabase.cs create mode 100644 University/DatabaseImplement/UniversityDatabaseImplement.csproj diff --git a/University/DatabaseImplement/Implements/ActivityStorage.cs b/University/DatabaseImplement/Implements/ActivityStorage.cs new file mode 100644 index 0000000..8ccd6ea --- /dev/null +++ b/University/DatabaseImplement/Implements/ActivityStorage.cs @@ -0,0 +1,12 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.SearchModels; +using UniversityContracts.StoragesContracts; +using UniversityContracts.ViewModels; +using UniversityDatabaseImplement.Models; + +namespace UniversityDatabaseImplement.Implements +{ + internal class ActivityStorage : IActivityStorage + { + } +} diff --git a/University/DatabaseImplement/Implements/DisciplineStorage.cs b/University/DatabaseImplement/Implements/DisciplineStorage.cs new file mode 100644 index 0000000..e55cbf7 --- /dev/null +++ b/University/DatabaseImplement/Implements/DisciplineStorage.cs @@ -0,0 +1,12 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.SearchModels; +using UniversityContracts.StoragesContracts; +using UniversityContracts.ViewModels; +using UniversityDatabaseImplement.Models; + +namespace UniversityDatabaseImplement.Implements +{ + internal class DisciplineStorage : IDisciplineStorage + { + } +} diff --git a/University/DatabaseImplement/Implements/ExaminationResultStorage.cs b/University/DatabaseImplement/Implements/ExaminationResultStorage.cs new file mode 100644 index 0000000..e8c8343 --- /dev/null +++ b/University/DatabaseImplement/Implements/ExaminationResultStorage.cs @@ -0,0 +1,12 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.SearchModels; +using UniversityContracts.StoragesContracts; +using UniversityContracts.ViewModels; +using UniversityDatabaseImplement.Models; + +namespace UniversityDatabaseImplement.Implements +{ + internal class ExaminationResultStorage : IExaminationResultStorage + { + } +} diff --git a/University/DatabaseImplement/Implements/ReportTypeStorage.cs b/University/DatabaseImplement/Implements/ReportTypeStorage.cs new file mode 100644 index 0000000..4dbf87d --- /dev/null +++ b/University/DatabaseImplement/Implements/ReportTypeStorage.cs @@ -0,0 +1,12 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.SearchModels; +using UniversityContracts.StoragesContracts; +using UniversityContracts.ViewModels; +using UniversityDatabaseImplement.Models; + +namespace UniversityDatabaseImplement.Implements +{ + internal class ReportTypeStorage : IReportTypeStorage + { + } +} diff --git a/University/DatabaseImplement/Implements/StatementStorage.cs b/University/DatabaseImplement/Implements/StatementStorage.cs new file mode 100644 index 0000000..fdce169 --- /dev/null +++ b/University/DatabaseImplement/Implements/StatementStorage.cs @@ -0,0 +1,12 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.SearchModels; +using UniversityContracts.StoragesContracts; +using UniversityContracts.ViewModels; +using UniversityDatabaseImplement.Models; + +namespace UniversityDatabaseImplement.Implements +{ + internal class StatementStorage : IStatementStorage + { + } +} diff --git a/University/DatabaseImplement/Implements/StudentStorage.cs b/University/DatabaseImplement/Implements/StudentStorage.cs new file mode 100644 index 0000000..8943ff4 --- /dev/null +++ b/University/DatabaseImplement/Implements/StudentStorage.cs @@ -0,0 +1,12 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.SearchModels; +using UniversityContracts.StoragesContracts; +using UniversityContracts.ViewModels; +using UniversityDatabaseImplement.Models; + +namespace UniversityDatabaseImplement.Implements +{ + internal class StudentStorage : IStudentStorage + { + } +} diff --git a/University/DatabaseImplement/Models/Activity.cs b/University/DatabaseImplement/Models/Activity.cs new file mode 100644 index 0000000..c630895 --- /dev/null +++ b/University/DatabaseImplement/Models/Activity.cs @@ -0,0 +1,19 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; +using UniversityDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace UniversityDatabaseImplement.Models +{ + public class Activity : IActivityModel + { + public int Id { get; set; } + [Required] + public DateTime Date { get; set; } + [Required] + public int Number { get; set; } + [ForeignKey("ActivityId")] + public virtual List ReportTypeActivities { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/Discipline.cs b/University/DatabaseImplement/Models/Discipline.cs new file mode 100644 index 0000000..9d0eb80 --- /dev/null +++ b/University/DatabaseImplement/Models/Discipline.cs @@ -0,0 +1,21 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; +using UniversityDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace UniversityDatabaseImplement.Models +{ + public class Discipline : IDisciplineModel + { + public int Id { get; set; } + [Required] + public string Name { get; set; } + [Required] + public string Department { get; set; } + [ForeignKey("DisciplineId")] + public virtual List Statements { get; set; } = new(); + [ForeignKey("DisciplineId")] + public virtual List ReportTypeDisciplines { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/ExaminationResult.cs b/University/DatabaseImplement/Models/ExaminationResult.cs new file mode 100644 index 0000000..15bdf1d --- /dev/null +++ b/University/DatabaseImplement/Models/ExaminationResult.cs @@ -0,0 +1,23 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; +using UniversityDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using UniversityDataModels.Enums; + +namespace UniversityDatabaseImplement.Models +{ + public class ExaminationResult : IExaminationResultModel + { + public int Id { get; set; } + public string ExaminationForm { get; set; } + [Required] + public MarkType Mark { get; set; } + [Required] + public DateTime Date { get; set; } + [ForeignKey("ExaminationResultId")] + public virtual List Activities { get; set; } = new(); + [ForeignKey("ExaminationResultId")] + public virtual List StudentExaminationResults { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/ReportType.cs b/University/DatabaseImplement/Models/ReportType.cs new file mode 100644 index 0000000..c51f37e --- /dev/null +++ b/University/DatabaseImplement/Models/ReportType.cs @@ -0,0 +1,19 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; +using UniversityDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace UniversityDatabaseImplement.Models +{ + public class ReportType : IReportTypeModel + { + public int Id { get; set; } + [Required] + public string Name { get; set; } + [ForeignKey("ReportTypeId")] + public virtual List ReportTypeActivities { get; set; } = new(); + [ForeignKey("ReportTypeId")] + public virtual List ReportTypeDisciplines { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/ReportTypeActivity.cs b/University/DatabaseImplement/Models/ReportTypeActivity.cs new file mode 100644 index 0000000..16d3223 --- /dev/null +++ b/University/DatabaseImplement/Models/ReportTypeActivity.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace UniversityDatabaseImplement.Models +{ + public class ReportTypeActivity + { + public int Id { get; set; } + [Required] + public int ReportTypeId { get; set; } + [Required] + public int ActivityId { get; set; } + public virtual ReportType ReportType { get; set; } = new(); + public virtual Activity Activity { get; set; } = new(); + + } +} diff --git a/University/DatabaseImplement/Models/ReportTypeDiscipline.cs b/University/DatabaseImplement/Models/ReportTypeDiscipline.cs new file mode 100644 index 0000000..ebccaca --- /dev/null +++ b/University/DatabaseImplement/Models/ReportTypeDiscipline.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace UniversityDatabaseImplement.Models +{ + public class ReportTypeDiscipline + { + public int Id { get; set; } + [Required] + public int ReportTypeId { get; set; } + [Required] + public int DisciplineId { get; set; } + public virtual ReportType ReportType { get; set; } = new(); + public virtual Discipline Discipline { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/Statement.cs b/University/DatabaseImplement/Models/Statement.cs new file mode 100644 index 0000000..4ebfa57 --- /dev/null +++ b/University/DatabaseImplement/Models/Statement.cs @@ -0,0 +1,21 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; +using UniversityDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace UniversityDatabaseImplement.Models +{ + public class Statement : IStatementModel + { + public int Id { get; set; } + [Required] + public DateTime Date { get; set; } + [Required] + public int HoursCount { get; set; } + [ForeignKey("StatementId")] + public virtual List StatementStudents { get; set; } = new(); + [ForeignKey("StatementId")] + public virtual List ExaminationResults { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/StatementStudent.cs b/University/DatabaseImplement/Models/StatementStudent.cs new file mode 100644 index 0000000..e82fac9 --- /dev/null +++ b/University/DatabaseImplement/Models/StatementStudent.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace UniversityDatabaseImplement.Models +{ + public class StatementStudent + { + public int Id { get; set; } + [Required] + public int StudentTypeId { get; set; } + [Required] + public int StatementId { get; set; } + public virtual Student Student { get; set; } = new(); + public virtual Statement Statement { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/Student.cs b/University/DatabaseImplement/Models/Student.cs new file mode 100644 index 0000000..80860a9 --- /dev/null +++ b/University/DatabaseImplement/Models/Student.cs @@ -0,0 +1,21 @@ +using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; +using UniversityDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace UniversityDatabaseImplement.Models +{ + public class Student : IStudentModel + { + public int Id { get; set; } + [Required] + public string Name { get; set; } + [Required] + public string RecordCardNumber { get; set; } + [ForeignKey("StudentId")] + public virtual List StatementStudents { get; set; } = new(); + [ForeignKey("StudentId")] + public virtual List StudentExaminationResults { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/Models/StudentExaminationResult.cs b/University/DatabaseImplement/Models/StudentExaminationResult.cs new file mode 100644 index 0000000..60a6664 --- /dev/null +++ b/University/DatabaseImplement/Models/StudentExaminationResult.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace UniversityDatabaseImplement.Models +{ + public class StudentExaminationResult + { + public int Id { get; set; } + [Required] + public int ExaminationResultId { get; set; } + [Required] + public int StudentId { get; set; } + public virtual ExaminationResult ExaminationResult { get; set; } = new(); + public virtual Student Student { get; set; } = new(); + } +} diff --git a/University/DatabaseImplement/UniversityDatabase.cs b/University/DatabaseImplement/UniversityDatabase.cs new file mode 100644 index 0000000..c429b98 --- /dev/null +++ b/University/DatabaseImplement/UniversityDatabase.cs @@ -0,0 +1,27 @@ +using UniversityDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace PizzeriaDatabaseImplement +{ + public class PizzeriaDatabase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=UniversityDatabase;Username=postgres;Password=postgres"); + } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet Activity { set; get; } + public virtual DbSet Discipline { set; get; } + public virtual DbSet ExaminationResult { set; get; } + public virtual DbSet ReportType { set; get; } + public virtual DbSet ReportTypeActivity { set; get; } + public virtual DbSet ReportTypeDiscipline { set; get; } + public virtual DbSet Statement { set; get; } + public virtual DbSet StatementStudent { set; get; } + public virtual DbSet Student { set; get; } + public virtual DbSet StudentExaminationResult { set; get; } + } +} \ No newline at end of file diff --git a/University/DatabaseImplement/UniversityDatabaseImplement.csproj b/University/DatabaseImplement/UniversityDatabaseImplement.csproj new file mode 100644 index 0000000..afd6b55 --- /dev/null +++ b/University/DatabaseImplement/UniversityDatabaseImplement.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + diff --git a/University/University.sln b/University/University.sln index 3f08cdf..2aa590b 100644 --- a/University/University.sln +++ b/University/University.sln @@ -5,9 +5,11 @@ VisualStudioVersion = 17.1.32319.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "University", "University\University.csproj", "{34B9CDDB-BFE5-48B9-AA3A-1A01D99A765D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDataModels", "UniversityDataModels\UniversityDataModels.csproj", "{36B2DE4B-7689-4287-911E-892FCD27AE84}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataModels", "UniversityDataModels\UniversityDataModels.csproj", "{36B2DE4B-7689-4287-911E-892FCD27AE84}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityContracts", "UniversityContracts\UniversityContracts.csproj", "{BACEFD46-1073-4730-BC42-15B0D0D359C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityContracts", "UniversityContracts\UniversityContracts.csproj", "{BACEFD46-1073-4730-BC42-15B0D0D359C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDatabaseImplement", "DatabaseImplement\UniversityDatabaseImplement.csproj", "{E90DAE97-8D0D-4E8E-89BC-82D3B54DA067}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,6 +29,10 @@ Global {BACEFD46-1073-4730-BC42-15B0D0D359C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {BACEFD46-1073-4730-BC42-15B0D0D359C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {BACEFD46-1073-4730-BC42-15B0D0D359C9}.Release|Any CPU.Build.0 = Release|Any CPU + {E90DAE97-8D0D-4E8E-89BC-82D3B54DA067}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E90DAE97-8D0D-4E8E-89BC-82D3B54DA067}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E90DAE97-8D0D-4E8E-89BC-82D3B54DA067}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E90DAE97-8D0D-4E8E-89BC-82D3B54DA067}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE