Сделал все модели и возможность подключения к бд

This commit is contained in:
Илья 2024-05-03 22:21:04 +04:00
parent 7db9c29959
commit d43bdadd20
16 changed files with 214 additions and 0 deletions

View File

@ -5,6 +5,10 @@ VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicDiaryView", "ElectronicDiaryView\ElectronicDiaryView.csproj", "{10EDFF55-E102-493B-9725-D8DC5498A286}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicDiaryAbstractions", "ElectronicDiaryAbstractions\ElectronicDiaryAbstractions.csproj", "{5E4A8B65-0CCB-448F-A39A-A987B6904E08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicDiaryPostgresImplementation", "ElectronicDiaryPostgresImplementation\ElectronicDiaryPostgresImplementation.csproj", "{2ED128E3-A299-4AA8-9607-6B528CDD66A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +19,14 @@ Global
{10EDFF55-E102-493B-9725-D8DC5498A286}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10EDFF55-E102-493B-9725-D8DC5498A286}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10EDFF55-E102-493B-9725-D8DC5498A286}.Release|Any CPU.Build.0 = Release|Any CPU
{5E4A8B65-0CCB-448F-A39A-A987B6904E08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E4A8B65-0CCB-448F-A39A-A987B6904E08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E4A8B65-0CCB-448F-A39A-A987B6904E08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E4A8B65-0CCB-448F-A39A-A987B6904E08}.Release|Any CPU.Build.0 = Release|Any CPU
{2ED128E3-A299-4AA8-9607-6B528CDD66A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2ED128E3-A299-4AA8-9607-6B528CDD66A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2ED128E3-A299-4AA8-9607-6B528CDD66A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2ED128E3-A299-4AA8-9607-6B528CDD66A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,11 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Grade
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public int TeacherId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Homework
{
public int Id { get; set; }
public string Description { get; set; } = string.Empty;
public DateTime Deadline { get; set; }
public bool IsAccepted { get; set; }
public int MarkId { get; set; }
}
}

View File

@ -0,0 +1,25 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Lesson
{
public int Id { get; set; }
public DateTime LessonDate { get; set; }
public bool IsMissed { get; set; }
public string TeacherComment { get; set; } = string.Empty;
public int MarkId { get; set; }
public int HomeworkId { get; set; }
public int StudentId { get; set; }
public int SubjectId { get; set; }
public int TeacherId { get; set; }
public int StudyAreaId { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Mark
{
public int Id { get; set; }
public int Value { get; set; }
}
}

View File

@ -0,0 +1,17 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Student
{
public int Id { get; set; }
public string LastName { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public int GradeId { get; set; }
public int UserId { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace ElectronicDiaryAbstractions.Models
{
public class StudyArea
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Type { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,9 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Subject
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,9 @@
namespace ElectronicDiaryAbstractions.Models
{
public class SubjectStudent
{
public int SubjectId { get; set; }
public int StudentId { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ElectronicDiaryAbstractions.Models
{
public class SubjectTeacher
{
public int SubjectId { get; set; }
public int TeacherId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
namespace ElectronicDiaryAbstractions.Models
{
public class Teacher
{
public int Id { get; set; }
public string LastName { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public int UserId { get; set; }
}
}

View File

@ -0,0 +1,17 @@
namespace ElectronicDiaryAbstractions.Models
{
public class User
{
public int Id { get; set; }
public string Login { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public string AccessLevel { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using ElectronicDiaryAbstractions.Models;
namespace ElectronicDiaryAbstractions.WorkAbstractions
{
public interface ISubjectWork
{
List<Subject> GetAll();
Subject Get(int id);
Subject Create(Subject subject);
Subject Update(Subject subject);
Subject Delete(int id);
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="WorkImplementation\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="8.0.2" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using Npgsql;
namespace ElectronicDiaryPostgresImplementation
{
public class SqlConnection
{
public static NpgsqlConnection GetConnection()
{
return new NpgsqlConnection("Host=localhost;Port=5432;Username=postgres;Database=diary_bd;Password=bythop423956");
}
}
}