From 8563387642f75f185a16b039a5cc34f8e879450a Mon Sep 17 00:00:00 2001 From: bekodeg Date: Wed, 6 Nov 2024 23:20:09 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=80=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D1=8F=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=BE=D0=B9=20=D1=82=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=86=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Lab3.Database/Extensions/DIExtension.cs | 1 + .../EducationFormRepository.cs | 34 +++++++++++++++++++ .../Interfaces/IEducationFormRepository.cs | 9 +++++ .../Lab3/Extensions/DIExtension.cs | 1 + .../Lab3/Forms/CreateForm.Designer.cs | 27 ++++++++++++++- Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs | 17 ++++------ Cop.Borovkov.Var3/Lab3/Program.cs | 2 +- 7 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/EducationFormRepository.cs create mode 100644 Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IEducationFormRepository.cs diff --git a/Cop.Borovkov.Var3/Lab3.Database/Extensions/DIExtension.cs b/Cop.Borovkov.Var3/Lab3.Database/Extensions/DIExtension.cs index d749c36..f623e96 100644 --- a/Cop.Borovkov.Var3/Lab3.Database/Extensions/DIExtension.cs +++ b/Cop.Borovkov.Var3/Lab3.Database/Extensions/DIExtension.cs @@ -41,6 +41,7 @@ namespace Lab3.Database.Extensions this IServiceCollection services) { services.AddScoped(); + services.AddScoped(); return services; } diff --git a/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/EducationFormRepository.cs b/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/EducationFormRepository.cs new file mode 100644 index 0000000..5bcb5d9 --- /dev/null +++ b/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/EducationFormRepository.cs @@ -0,0 +1,34 @@ +using Lab3.Database.Context; +using Lab3.Database.Models; +using Lab3.Database.Repository.Interfaces; +using Microsoft.EntityFrameworkCore; + +namespace Lab3.Database.Repository.Implementations +{ + public class EducationFormRepository : IEducationFormRepository + { + private readonly COPContext _context; + + public EducationFormRepository(COPContext context) + { + _context = context; + } + + public async Task> Get() + { + return await _context.EducationForms + .Select(f => f.Name) + .ToListAsync(); + } + + public async Task Update(IEnumerable educationForms) + { + await _context.EducationForms.ExecuteDeleteAsync(); + await _context.EducationForms.AddRangeAsync(educationForms.Select(f => new EducationForm() + { + Id = Guid.NewGuid(), + Name = f, + })); + } + } +} diff --git a/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IEducationFormRepository.cs b/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IEducationFormRepository.cs new file mode 100644 index 0000000..355c69e --- /dev/null +++ b/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IEducationFormRepository.cs @@ -0,0 +1,9 @@ +namespace Lab3.Database.Repository.Interfaces +{ + public interface IEducationFormRepository + { + Task> Get(); + + Task Update(IEnumerable educationForms); + } +} diff --git a/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs b/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs index 5962a2f..d209df7 100644 --- a/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs +++ b/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs @@ -23,6 +23,7 @@ namespace Lab3.Extensions this IServiceCollection services) { services.AddScoped(); + services.AddScoped(); return services; } diff --git a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs index be38e3e..fdc03ad 100644 --- a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs +++ b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs @@ -47,6 +47,8 @@ numericUpDown5 = new NumericUpDown(); label10 = new Label(); numericUpDown6 = new NumericUpDown(); + button1 = new Button(); + button2 = new Button(); ((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown3).BeginInit(); @@ -230,11 +232,31 @@ numericUpDown6.Size = new Size(150, 27); numericUpDown6.TabIndex = 13; // + // button1 + // + button1.Location = new Point(430, 258); + button1.Name = "button1"; + button1.Size = new Size(164, 39); + button1.TabIndex = 19; + button1.Text = "Сохранить"; + button1.UseVisualStyleBackColor = true; + // + // button2 + // + button2.Location = new Point(624, 258); + button2.Name = "button2"; + button2.Size = new Size(164, 39); + button2.TabIndex = 20; + button2.Text = "Отмена"; + button2.UseVisualStyleBackColor = true; + // // CreateForm // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 309); + Controls.Add(button2); + Controls.Add(button1); Controls.Add(label8); Controls.Add(numericUpDown4); Controls.Add(label9); @@ -255,7 +277,8 @@ Controls.Add(customDateTimePicker1); Controls.Add(visualSelectionComponent1); Name = "CreateForm"; - Text = "Сессия1"; + Text = "CreateForm"; + Load += CreateForm_Load; ((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown3).EndInit(); @@ -287,5 +310,7 @@ private NumericUpDown numericUpDown5; private Label label10; private NumericUpDown numericUpDown6; + private Button button1; + private Button button2; } } \ No newline at end of file diff --git a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs index c1d3860..e3bb90c 100644 --- a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs +++ b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs @@ -1,20 +1,17 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using Lab3.Database.Repository.Interfaces; namespace Lab3.Forms { public partial class CreateForm : Form { - public CreateForm() + public CreateForm(IStudentRepository student) { InitializeComponent(); } + + private void CreateForm_Load(object sender, EventArgs e) + { + + } } } diff --git a/Cop.Borovkov.Var3/Lab3/Program.cs b/Cop.Borovkov.Var3/Lab3/Program.cs index 2ac9d73..46a396d 100644 --- a/Cop.Borovkov.Var3/Lab3/Program.cs +++ b/Cop.Borovkov.Var3/Lab3/Program.cs @@ -21,7 +21,7 @@ namespace Lab3 var app = CreateHostBuilder().Build(); - Application.Run(app.Services.GetRequiredService()); + Application.Run(app.Services.GetRequiredService()); } static IHostBuilder CreateHostBuilder()