From aa5c773d5a7bab4d8c255622c4e457ccc47d6876 Mon Sep 17 00:00:00 2001 From: funa4i Date: Mon, 18 Nov 2024 16:07:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StudentProgressRecord/Entity/Subject.cs | 3 ++- .../Forms/FormsEntity/FormSubject.cs | 4 ++-- .../RepositoryImp/SubjectRepository.cs | 13 +++++-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/StudentProgressRecord/Entity/Subject.cs b/StudentProgressRecord/Entity/Subject.cs index 7b863ad..16598d6 100644 --- a/StudentProgressRecord/Entity/Subject.cs +++ b/StudentProgressRecord/Entity/Subject.cs @@ -20,7 +20,8 @@ namespace StudentProgressRecord.Entity return new Subject { Id = id, - Name = name + Name = name, + direction = direction }; } } diff --git a/StudentProgressRecord/Forms/FormsEntity/FormSubject.cs b/StudentProgressRecord/Forms/FormsEntity/FormSubject.cs index 455c77e..5ceb3ac 100644 --- a/StudentProgressRecord/Forms/FormsEntity/FormSubject.cs +++ b/StudentProgressRecord/Forms/FormsEntity/FormSubject.cs @@ -62,8 +62,8 @@ namespace StudentProgressRecord { try { - if (string.IsNullOrWhiteSpace(textBoxSubject.Text) || - string.IsNullOrWhiteSpace(textBoxSubject.Text)) + if (string.IsNullOrWhiteSpace(textBoxSubject.Text) || + checkedListBoxDir.CheckedItems.Count == 0) { throw new Exception("Имя не может быть пустым"); } diff --git a/StudentProgressRecord/RepositoryImp/SubjectRepository.cs b/StudentProgressRecord/RepositoryImp/SubjectRepository.cs index 47efba3..399e127 100644 --- a/StudentProgressRecord/RepositoryImp/SubjectRepository.cs +++ b/StudentProgressRecord/RepositoryImp/SubjectRepository.cs @@ -3,13 +3,10 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Npgsql; using StudentProgressRecord.Entity; +using StudentProgressRecord.Entity.Enums; using StudentProgressRecord.IRepositories; using StudentProgressRecord.Repositories; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace StudentProgressRecord.RepositoryImp { @@ -32,8 +29,8 @@ namespace StudentProgressRecord.RepositoryImp { using var connection = new NpgsqlConnection(_connectionString.GetConnectionString()); var query = @" - INSERT INTO Subject (Name) - VALUES (@Name)"; + INSERT INTO Subject (direction, Name) + VALUES (@direction ,@Name)"; connection.Execute(query, subject); } catch (Exception ex) @@ -64,7 +61,7 @@ namespace StudentProgressRecord.RepositoryImp public Subject ReadSubjectById(long id) { - return Subject.CreateEntity(0, string.Empty); + return Subject.CreateEntity(0, string.Empty, Direction.None); } public IEnumerable ReadSubjects()