вроде все

This commit is contained in:
funa4i 2024-11-18 16:07:41 +04:00
parent d87c72750b
commit aa5c773d5a
3 changed files with 9 additions and 11 deletions

View File

@ -20,7 +20,8 @@ namespace StudentProgressRecord.Entity
return new Subject return new Subject
{ {
Id = id, Id = id,
Name = name Name = name,
direction = direction
}; };
} }
} }

View File

@ -62,8 +62,8 @@ namespace StudentProgressRecord
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(textBoxSubject.Text) || if (string.IsNullOrWhiteSpace(textBoxSubject.Text) ||
string.IsNullOrWhiteSpace(textBoxSubject.Text)) checkedListBoxDir.CheckedItems.Count == 0)
{ {
throw new Exception("Имя не может быть пустым"); throw new Exception("Имя не может быть пустым");
} }

View File

@ -3,13 +3,10 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Npgsql; using Npgsql;
using StudentProgressRecord.Entity; using StudentProgressRecord.Entity;
using StudentProgressRecord.Entity.Enums;
using StudentProgressRecord.IRepositories; using StudentProgressRecord.IRepositories;
using StudentProgressRecord.Repositories; using StudentProgressRecord.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StudentProgressRecord.RepositoryImp namespace StudentProgressRecord.RepositoryImp
{ {
@ -32,8 +29,8 @@ namespace StudentProgressRecord.RepositoryImp
{ {
using var connection = new NpgsqlConnection(_connectionString.GetConnectionString()); using var connection = new NpgsqlConnection(_connectionString.GetConnectionString());
var query = @" var query = @"
INSERT INTO Subject (Name) INSERT INTO Subject (direction, Name)
VALUES (@Name)"; VALUES (@direction ,@Name)";
connection.Execute(query, subject); connection.Execute(query, subject);
} }
catch (Exception ex) catch (Exception ex)
@ -64,7 +61,7 @@ namespace StudentProgressRecord.RepositoryImp
public Subject ReadSubjectById(long id) public Subject ReadSubjectById(long id)
{ {
return Subject.CreateEntity(0, string.Empty); return Subject.CreateEntity(0, string.Empty, Direction.None);
} }
public IEnumerable<Subject> ReadSubjects() public IEnumerable<Subject> ReadSubjects()