From 2c0e6b13f594663cd20e8029f96802bab1535f77 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Thu, 7 Nov 2024 13:41:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Lab3.Database/DTO/StudentSessionDTO.cs | 2 - .../MappingProfiles/SessionMappingProfile.cs | 3 +- .../Implementations/StudentRepository.cs | 45 ++- .../Interfaces/IStudentRepository.cs | 10 +- .../Lab3/Extensions/DIExtension.cs | 12 +- .../Lab3/Forms/CreateForm.Designer.cs | 257 +++++++++--------- Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs | 76 +++++- Cop.Borovkov.Var3/Lab3/Forms/MainForm.cs | 2 +- Cop.Borovkov.Var3/Lab3/Lab3.csproj | 4 +- Cop.Borovkov.Var3/Lab3/Program.cs | 2 +- 10 files changed, 263 insertions(+), 150 deletions(-) diff --git a/Cop.Borovkov.Var3/Lab3.Database/DTO/StudentSessionDTO.cs b/Cop.Borovkov.Var3/Lab3.Database/DTO/StudentSessionDTO.cs index 8155a74..52da42d 100644 --- a/Cop.Borovkov.Var3/Lab3.Database/DTO/StudentSessionDTO.cs +++ b/Cop.Borovkov.Var3/Lab3.Database/DTO/StudentSessionDTO.cs @@ -2,8 +2,6 @@ { public record StudentSessionDTO { - public Guid Id { get; init; } - public decimal Score { get; init; } public int Number { get; init; } diff --git a/Cop.Borovkov.Var3/Lab3.Database/MappingProfiles/SessionMappingProfile.cs b/Cop.Borovkov.Var3/Lab3.Database/MappingProfiles/SessionMappingProfile.cs index 31b547a..b56d35b 100644 --- a/Cop.Borovkov.Var3/Lab3.Database/MappingProfiles/SessionMappingProfile.cs +++ b/Cop.Borovkov.Var3/Lab3.Database/MappingProfiles/SessionMappingProfile.cs @@ -9,7 +9,8 @@ namespace Lab3.Database.MappingProfiles public SessionMappingProfile() { _ = CreateMap(); - _ = CreateMap(); + _ = CreateMap() + .ForMember(s => s.Id, opt => opt.MapFrom(s => Guid.NewGuid())); } } } diff --git a/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs b/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs index 1db612e..8f0d2f0 100644 --- a/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs +++ b/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs @@ -1,6 +1,7 @@ using AutoMapper; using Lab3.Database.Context; using Lab3.Database.DTO; +using Lab3.Database.Models; using Lab3.Database.Repository.Interfaces; using Microsoft.EntityFrameworkCore; @@ -18,10 +19,19 @@ namespace Lab3.Database.Repository.Implementations _context = context; } - public Task> Create(StudentDTO studentDTO) => throw new NotImplementedException(); - public Task Delete(Guid id) => throw new NotImplementedException(); + public async Task CreateAsync(StudentDTO studentDTO) + { + var student = _mapper.Map(studentDTO); - public async Task> Get(int limit = 10000, int offset = 0) + var result = await _context.Students.AddAsync(student); + await _context.SaveChangesAsync(); + + return _mapper.Map(result.Entity); + } + + public Task DeleteAsync(Guid id) => throw new NotImplementedException(); + + public async Task> GetAsync(int limit = 10000, int offset = 0) => _mapper.Map>( await _context.Students .Include(s => s.StudentSessions) @@ -29,7 +39,32 @@ namespace Lab3.Database.Repository.Implementations .Take(limit) .ToListAsync()); - public Task Get(Guid id) => throw new NotImplementedException(); - public Task Update(StudentDTO studentDTO) => throw new NotImplementedException(); + public Task GetAsync(Guid id) => throw new NotImplementedException(); + + public async Task UpdateAsync(StudentDTO studentDTO) + { + var student = _mapper.Map(studentDTO); + + var currStudent = await _context.Students.FindAsync(student.Id); + + if (currStudent == null) + { + return null; + } + + currStudent.Name = student.Name; + currStudent.StartEducation = student.StartEducation; + currStudent.EducationForm = student.EducationForm; + + foreach (var session in currStudent.StudentSessions) + { + session.Score = student.StudentSessions + .FirstOrDefault(s => s.Number == session.Number)?.Score ?? session.Score; + } + + await _context.SaveChangesAsync(); + + return _mapper.Map(currStudent); + } } } diff --git a/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IStudentRepository.cs b/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IStudentRepository.cs index 968ded3..6561dc0 100644 --- a/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IStudentRepository.cs +++ b/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IStudentRepository.cs @@ -4,14 +4,14 @@ namespace Lab3.Database.Repository.Interfaces { public interface IStudentRepository { - public Task> Get(int limit = 10000, int offset = 0); + public Task> GetAsync(int limit = 10000, int offset = 0); - public Task Get(Guid id); + public Task GetAsync(Guid id); - public Task Update(StudentDTO studentDTO); + public Task UpdateAsync(StudentDTO studentDTO); - public Task Delete(Guid id); + public Task DeleteAsync(Guid id); - public Task> Create(StudentDTO studentDTO); + public Task CreateAsync(StudentDTO studentDTO); } } diff --git a/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs b/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs index d209df7..11ef788 100644 --- a/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs +++ b/Cop.Borovkov.Var3/Lab3/Extensions/DIExtension.cs @@ -1,4 +1,6 @@ -using Lab3.Database.Extensions; +using DocumentFormat.OpenXml.Office2010.Excel; +using Lab3.Database.Extensions; +using Lab3.Database.Repository.Interfaces; using Lab3.Forms; using Lab3.MappingProfiles; using Microsoft.Extensions.Configuration; @@ -23,7 +25,13 @@ namespace Lab3.Extensions this IServiceCollection services) { services.AddScoped(); - services.AddScoped(); + + services.AddScoped>(sp => (id + => new CreateForm( + sp.GetRequiredService(), + sp.GetRequiredService(), + id + ))); return services; } diff --git a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs index fdc03ad..aab5988 100644 --- a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs +++ b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs @@ -28,52 +28,52 @@ /// private void InitializeComponent() { - customDateTimePicker1 = new CustomsComponentsVar2.CustomDateTimePicker(); - visualSelectionComponent1 = new ComponentsLab.VisualSelectionComponent(); + StartEducationDataPicker = new CustomsComponentsVar2.CustomDateTimePicker(); + FormSelector = new ComponentsLab.VisualSelectionComponent(); label1 = new Label(); label2 = new Label(); - textBox1 = new TextBox(); + NameTextBox = new TextBox(); label3 = new Label(); - numericUpDown1 = new NumericUpDown(); + session1Score = new NumericUpDown(); label4 = new Label(); label5 = new Label(); label6 = new Label(); - numericUpDown2 = new NumericUpDown(); + session2Score = new NumericUpDown(); label7 = new Label(); - numericUpDown3 = new NumericUpDown(); + session3Score = new NumericUpDown(); label8 = new Label(); - numericUpDown4 = new NumericUpDown(); + session6Score = new NumericUpDown(); label9 = new Label(); - numericUpDown5 = new NumericUpDown(); + session5Score = 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(); - ((System.ComponentModel.ISupportInitialize)numericUpDown4).BeginInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown5).BeginInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown6).BeginInit(); + session4Score = new NumericUpDown(); + ButtonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)session1Score).BeginInit(); + ((System.ComponentModel.ISupportInitialize)session2Score).BeginInit(); + ((System.ComponentModel.ISupportInitialize)session3Score).BeginInit(); + ((System.ComponentModel.ISupportInitialize)session6Score).BeginInit(); + ((System.ComponentModel.ISupportInitialize)session5Score).BeginInit(); + ((System.ComponentModel.ISupportInitialize)session4Score).BeginInit(); SuspendLayout(); // - // customDateTimePicker1 + // StartEducationDataPicker // - customDateTimePicker1.Location = new Point(430, 32); - customDateTimePicker1.Name = "customDateTimePicker1"; - customDateTimePicker1.Size = new Size(456, 55); - customDateTimePicker1.TabIndex = 0; - customDateTimePicker1.Value = new DateTime(2024, 11, 6, 22, 54, 54, 353); + StartEducationDataPicker.Location = new Point(430, 32); + StartEducationDataPicker.Name = "StartEducationDataPicker"; + StartEducationDataPicker.Size = new Size(456, 55); + StartEducationDataPicker.TabIndex = 0; + StartEducationDataPicker.Value = new DateTime(2024, 11, 6, 22, 54, 54, 353); // - // visualSelectionComponent1 + // FormSelector // - visualSelectionComponent1.BorderStyle = BorderStyle.FixedSingle; - visualSelectionComponent1.comboBoxSelectedValue = ""; - visualSelectionComponent1.Location = new Point(430, 114); - visualSelectionComponent1.Margin = new Padding(3, 4, 3, 4); - visualSelectionComponent1.Name = "visualSelectionComponent1"; - visualSelectionComponent1.Size = new Size(211, 109); - visualSelectionComponent1.TabIndex = 1; + FormSelector.BorderStyle = BorderStyle.FixedSingle; + FormSelector.ComboBoxSelectedValue = ""; + FormSelector.Location = new Point(436, 133); + FormSelector.Margin = new Padding(3, 4, 3, 4); + FormSelector.Name = "FormSelector"; + FormSelector.Size = new Size(352, 31); + FormSelector.TabIndex = 1; // // label1 // @@ -87,18 +87,18 @@ // label2 // label2.AutoSize = true; - label2.Location = new Point(436, 90); + label2.Location = new Point(436, 101); label2.Name = "label2"; label2.Size = new Size(128, 20); label2.TabIndex = 3; label2.Text = "Форма обучения"; // - // textBox1 + // NameTextBox // - textBox1.Location = new Point(12, 60); - textBox1.Name = "textBox1"; - textBox1.Size = new Size(315, 27); - textBox1.TabIndex = 4; + NameTextBox.Location = new Point(12, 60); + NameTextBox.Name = "NameTextBox"; + NameTextBox.Size = new Size(315, 27); + NameTextBox.TabIndex = 4; // // label3 // @@ -109,15 +109,15 @@ label3.TabIndex = 5; label3.Text = "ФИО"; // - // numericUpDown1 + // session1Score // - numericUpDown1.DecimalPlaces = 2; - numericUpDown1.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - numericUpDown1.Location = new Point(12, 156); - numericUpDown1.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); - numericUpDown1.Name = "numericUpDown1"; - numericUpDown1.Size = new Size(150, 27); - numericUpDown1.TabIndex = 6; + session1Score.DecimalPlaces = 2; + session1Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); + session1Score.Location = new Point(12, 156); + session1Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + session1Score.Name = "session1Score"; + session1Score.Size = new Size(150, 27); + session1Score.TabIndex = 6; // // label4 // @@ -146,15 +146,15 @@ label6.TabIndex = 10; label6.Text = "Сессия2"; // - // numericUpDown2 + // session2Score // - numericUpDown2.DecimalPlaces = 2; - numericUpDown2.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - numericUpDown2.Location = new Point(12, 211); - numericUpDown2.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); - numericUpDown2.Name = "numericUpDown2"; - numericUpDown2.Size = new Size(150, 27); - numericUpDown2.TabIndex = 9; + session2Score.DecimalPlaces = 2; + session2Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); + session2Score.Location = new Point(12, 211); + session2Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + session2Score.Name = "session2Score"; + session2Score.Size = new Size(150, 27); + session2Score.TabIndex = 9; // // label7 // @@ -165,15 +165,15 @@ label7.TabIndex = 12; label7.Text = "Сессия3"; // - // numericUpDown3 + // session3Score // - numericUpDown3.DecimalPlaces = 2; - numericUpDown3.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - numericUpDown3.Location = new Point(12, 270); - numericUpDown3.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); - numericUpDown3.Name = "numericUpDown3"; - numericUpDown3.Size = new Size(150, 27); - numericUpDown3.TabIndex = 11; + session3Score.DecimalPlaces = 2; + session3Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); + session3Score.Location = new Point(12, 270); + session3Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + session3Score.Name = "session3Score"; + session3Score.Size = new Size(150, 27); + session3Score.TabIndex = 11; // // label8 // @@ -184,15 +184,15 @@ label8.TabIndex = 18; label8.Text = "Сессия6"; // - // numericUpDown4 + // session6Score // - numericUpDown4.DecimalPlaces = 2; - numericUpDown4.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - numericUpDown4.Location = new Point(177, 270); - numericUpDown4.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); - numericUpDown4.Name = "numericUpDown4"; - numericUpDown4.Size = new Size(150, 27); - numericUpDown4.TabIndex = 17; + session6Score.DecimalPlaces = 2; + session6Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); + session6Score.Location = new Point(177, 270); + session6Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + session6Score.Name = "session6Score"; + session6Score.Size = new Size(150, 27); + session6Score.TabIndex = 17; // // label9 // @@ -203,15 +203,15 @@ label9.TabIndex = 16; label9.Text = "Сессия5"; // - // numericUpDown5 + // session5Score // - numericUpDown5.DecimalPlaces = 2; - numericUpDown5.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - numericUpDown5.Location = new Point(177, 211); - numericUpDown5.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); - numericUpDown5.Name = "numericUpDown5"; - numericUpDown5.Size = new Size(150, 27); - numericUpDown5.TabIndex = 15; + session5Score.DecimalPlaces = 2; + session5Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); + session5Score.Location = new Point(177, 211); + session5Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + session5Score.Name = "session5Score"; + session5Score.Size = new Size(150, 27); + session5Score.TabIndex = 15; // // label10 // @@ -222,95 +222,96 @@ label10.TabIndex = 14; label10.Text = "Сессия4"; // - // numericUpDown6 + // session4Score // - numericUpDown6.DecimalPlaces = 2; - numericUpDown6.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - numericUpDown6.Location = new Point(177, 156); - numericUpDown6.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); - numericUpDown6.Name = "numericUpDown6"; - numericUpDown6.Size = new Size(150, 27); - numericUpDown6.TabIndex = 13; + session4Score.DecimalPlaces = 2; + session4Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); + session4Score.Location = new Point(177, 156); + session4Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + session4Score.Name = "session4Score"; + session4Score.Size = new Size(150, 27); + session4Score.TabIndex = 13; // - // button1 + // ButtonSave // - button1.Location = new Point(430, 258); - button1.Name = "button1"; - button1.Size = new Size(164, 39); - button1.TabIndex = 19; - button1.Text = "Сохранить"; - button1.UseVisualStyleBackColor = true; + ButtonSave.Location = new Point(430, 258); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(164, 39); + ButtonSave.TabIndex = 19; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_ClickAsync; // - // button2 + // buttonCancel // - button2.Location = new Point(624, 258); - button2.Name = "button2"; - button2.Size = new Size(164, 39); - button2.TabIndex = 20; - button2.Text = "Отмена"; - button2.UseVisualStyleBackColor = true; + buttonCancel.Location = new Point(624, 258); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(164, 39); + buttonCancel.TabIndex = 20; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; // // CreateForm // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 309); - Controls.Add(button2); - Controls.Add(button1); + Controls.Add(buttonCancel); + Controls.Add(ButtonSave); Controls.Add(label8); - Controls.Add(numericUpDown4); + Controls.Add(session6Score); Controls.Add(label9); - Controls.Add(numericUpDown5); + Controls.Add(session5Score); Controls.Add(label10); - Controls.Add(numericUpDown6); + Controls.Add(session4Score); Controls.Add(label7); - Controls.Add(numericUpDown3); + Controls.Add(session3Score); Controls.Add(label6); - Controls.Add(numericUpDown2); + Controls.Add(session2Score); Controls.Add(label5); Controls.Add(label4); - Controls.Add(numericUpDown1); + Controls.Add(session1Score); Controls.Add(label3); - Controls.Add(textBox1); + Controls.Add(NameTextBox); Controls.Add(label2); Controls.Add(label1); - Controls.Add(customDateTimePicker1); - Controls.Add(visualSelectionComponent1); + Controls.Add(StartEducationDataPicker); + Controls.Add(FormSelector); Name = "CreateForm"; Text = "CreateForm"; - Load += CreateForm_Load; - ((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown3).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown4).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown5).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown6).EndInit(); + Load += CreateForm_LoadAsync; + ((System.ComponentModel.ISupportInitialize)session1Score).EndInit(); + ((System.ComponentModel.ISupportInitialize)session2Score).EndInit(); + ((System.ComponentModel.ISupportInitialize)session3Score).EndInit(); + ((System.ComponentModel.ISupportInitialize)session6Score).EndInit(); + ((System.ComponentModel.ISupportInitialize)session5Score).EndInit(); + ((System.ComponentModel.ISupportInitialize)session4Score).EndInit(); ResumeLayout(false); PerformLayout(); } #endregion - private CustomsComponentsVar2.CustomDateTimePicker customDateTimePicker1; - private ComponentsLab.VisualSelectionComponent visualSelectionComponent1; + private CustomsComponentsVar2.CustomDateTimePicker StartEducationDataPicker; + private ComponentsLab.VisualSelectionComponent FormSelector; private Label label1; private Label label2; - private TextBox textBox1; + private TextBox NameTextBox; private Label label3; - private NumericUpDown numericUpDown1; + private NumericUpDown session1Score; private Label label4; private Label label5; private Label label6; - private NumericUpDown numericUpDown2; + private NumericUpDown session2Score; private Label label7; - private NumericUpDown numericUpDown3; + private NumericUpDown session3Score; private Label label8; - private NumericUpDown numericUpDown4; + private NumericUpDown session6Score; private Label label9; - private NumericUpDown numericUpDown5; + private NumericUpDown session5Score; private Label label10; - private NumericUpDown numericUpDown6; - private Button button1; - private Button button2; + private NumericUpDown session4Score; + private Button ButtonSave; + private Button buttonCancel; } } \ 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 e3bb90c..e9a5049 100644 --- a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs +++ b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs @@ -1,17 +1,87 @@ -using Lab3.Database.Repository.Interfaces; +using Lab3.Database.DTO; +using Lab3.Database.Models; +using Lab3.Database.Repository.Interfaces; namespace Lab3.Forms { public partial class CreateForm : Form { - public CreateForm(IStudentRepository student) + private readonly IStudentRepository _studentRepository; + + private readonly IEducationFormRepository _educationFormRepository; + + private readonly Guid? _updatedStudentGuid = null; + + public CreateForm( + IStudentRepository studentRepository, + IEducationFormRepository educationFormRepository, + Guid? updatedStudentGuid) { + _studentRepository = studentRepository; + _educationFormRepository = educationFormRepository; + + _updatedStudentGuid = updatedStudentGuid; + InitializeComponent(); } - private void CreateForm_Load(object sender, EventArgs e) + private async void CreateForm_LoadAsync(object sender, EventArgs e) { + FormSelector.Fill(await _educationFormRepository.Get()); + StartEducationDataPicker.DateStart = DateTime.Now.AddYears(-6); + StartEducationDataPicker.DateEnd = DateTime.Now; + } + private async void ButtonSave_ClickAsync(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(NameTextBox.Text) + || string.IsNullOrEmpty(FormSelector.ComboBoxSelectedValue)) + { + throw new Exception(); + } + + StudentDTO student = new() + { + Id = _updatedStudentGuid ?? Guid.NewGuid(), + Name = NameTextBox.Text, + StartEducation = StartEducationDataPicker.Value, + EducationForm = FormSelector.ComboBoxSelectedValue, + StudentSessions = [ + new(){ + Score = session1Score.Value, + Number = 1, + }, + new(){ + Score = session2Score.Value, + Number = 2, + }, + new(){ + Score = session3Score.Value, + Number = 3, + }, + new(){ + Score = session4Score.Value, + Number = 4, + }, + new(){ + Score = session5Score.Value, + Number = 5, + }, + new(){ + Score = session6Score.Value, + Number = 6, + }, + ], + }; + + if (_updatedStudentGuid != null) + { + await _studentRepository.UpdateAsync(student); + } + else + { + await _studentRepository.CreateAsync(student); + } } } } diff --git a/Cop.Borovkov.Var3/Lab3/Forms/MainForm.cs b/Cop.Borovkov.Var3/Lab3/Forms/MainForm.cs index 5bdb12e..5a84939 100644 --- a/Cop.Borovkov.Var3/Lab3/Forms/MainForm.cs +++ b/Cop.Borovkov.Var3/Lab3/Forms/MainForm.cs @@ -20,7 +20,7 @@ namespace Lab3.Forms private async void MainForm_LoadAsync(object sender, EventArgs e) { - var students = _mapper.Map>(await _studentRepository.Get()); + var students = _mapper.Map>(await _studentRepository.GetAsync()); StudentsListBox.FillListBox(students); } } diff --git a/Cop.Borovkov.Var3/Lab3/Lab3.csproj b/Cop.Borovkov.Var3/Lab3/Lab3.csproj index db1aab1..19346e9 100644 --- a/Cop.Borovkov.Var3/Lab3/Lab3.csproj +++ b/Cop.Borovkov.Var3/Lab3/Lab3.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/Cop.Borovkov.Var3/Lab3/Program.cs b/Cop.Borovkov.Var3/Lab3/Program.cs index 46a396d..b98c3b6 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>()(null)); } static IHostBuilder CreateHostBuilder()