diff --git a/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs b/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs index 8f0d2f0..0b13144 100644 --- a/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs +++ b/Cop.Borovkov.Var3/Lab3.Database/Repository/Implementations/StudentRepository.cs @@ -39,7 +39,13 @@ namespace Lab3.Database.Repository.Implementations .Take(limit) .ToListAsync()); - public Task GetAsync(Guid id) => throw new NotImplementedException(); + public async Task GetAsync(Guid id) + { + return _mapper.Map( + await _context.Students + .Include(s => s.StudentSessions) + .FirstOrDefaultAsync()); + } public async Task UpdateAsync(StudentDTO studentDTO) { diff --git a/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IStudentRepository.cs b/Cop.Borovkov.Var3/Lab3.Database/Repository/Interfaces/IStudentRepository.cs index 6561dc0..4b1873f 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> GetAsync(int limit = 10000, int offset = 0); + Task> GetAsync(int limit = 10000, int offset = 0); - public Task GetAsync(Guid id); + Task GetAsync(Guid id); - public Task UpdateAsync(StudentDTO studentDTO); + Task UpdateAsync(StudentDTO studentDTO); - public Task DeleteAsync(Guid id); + Task DeleteAsync(Guid id); - public Task CreateAsync(StudentDTO studentDTO); + Task CreateAsync(StudentDTO studentDTO); } } diff --git a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs index e9a5049..9a6cb6f 100644 --- a/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs +++ b/Cop.Borovkov.Var3/Lab3/Forms/CreateForm.cs @@ -30,6 +30,29 @@ namespace Lab3.Forms FormSelector.Fill(await _educationFormRepository.Get()); StartEducationDataPicker.DateStart = DateTime.Now.AddYears(-6); StartEducationDataPicker.DateEnd = DateTime.Now; + + if (_updatedStudentGuid == null) + { + return; + } + var student = await _studentRepository.GetAsync(_updatedStudentGuid.Value); + + NameTextBox.Text = student.Name; + StartEducationDataPicker.Value = student.StartEducation; + FormSelector.ComboBoxSelectedValue = student.EducationForm; + + session1Score.Value = student.StudentSessions + .FirstOrDefault(s => s.Number == 1)?.Score ?? decimal.Zero; + session2Score.Value = student.StudentSessions + .FirstOrDefault(s => s.Number == 2)?.Score ?? decimal.Zero; + session3Score.Value = student.StudentSessions + .FirstOrDefault(s => s.Number == 3)?.Score ?? decimal.Zero; + session4Score.Value = student.StudentSessions + .FirstOrDefault(s => s.Number == 4)?.Score ?? decimal.Zero; + session5Score.Value = student.StudentSessions + .FirstOrDefault(s => s.Number == 5)?.Score ?? decimal.Zero; + session6Score.Value = student.StudentSessions + .FirstOrDefault(s => s.Number == 6)?.Score ?? decimal.Zero; } private async void ButtonSave_ClickAsync(object sender, EventArgs e) diff --git a/Cop.Borovkov.Var3/Lab3/Program.cs b/Cop.Borovkov.Var3/Lab3/Program.cs index b98c3b6..2ac9d73 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>()(null)); + Application.Run(app.Services.GetRequiredService()); } static IHostBuilder CreateHostBuilder()