Добил добавление и изменение
This commit is contained in:
parent
2c0e6b13f5
commit
09a8bc1857
@ -39,7 +39,13 @@ namespace Lab3.Database.Repository.Implementations
|
||||
.Take(limit)
|
||||
.ToListAsync());
|
||||
|
||||
public Task<StudentDTO> GetAsync(Guid id) => throw new NotImplementedException();
|
||||
public async Task<StudentDTO?> GetAsync(Guid id)
|
||||
{
|
||||
return _mapper.Map<StudentDTO>(
|
||||
await _context.Students
|
||||
.Include(s => s.StudentSessions)
|
||||
.FirstOrDefaultAsync());
|
||||
}
|
||||
|
||||
public async Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO)
|
||||
{
|
||||
|
@ -4,14 +4,14 @@ namespace Lab3.Database.Repository.Interfaces
|
||||
{
|
||||
public interface IStudentRepository
|
||||
{
|
||||
public Task<List<StudentDTO>> GetAsync(int limit = 10000, int offset = 0);
|
||||
Task<List<StudentDTO>> GetAsync(int limit = 10000, int offset = 0);
|
||||
|
||||
public Task<StudentDTO> GetAsync(Guid id);
|
||||
Task<StudentDTO?> GetAsync(Guid id);
|
||||
|
||||
public Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO);
|
||||
Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO);
|
||||
|
||||
public Task<StudentDTO> DeleteAsync(Guid id);
|
||||
Task<StudentDTO> DeleteAsync(Guid id);
|
||||
|
||||
public Task<StudentDTO> CreateAsync(StudentDTO studentDTO);
|
||||
Task<StudentDTO> CreateAsync(StudentDTO studentDTO);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -21,7 +21,7 @@ namespace Lab3
|
||||
|
||||
var app = CreateHostBuilder().Build();
|
||||
|
||||
Application.Run(app.Services.GetRequiredService<Func<Guid?, CreateForm>>()(null));
|
||||
Application.Run(app.Services.GetRequiredService<MainForm>());
|
||||
}
|
||||
|
||||
static IHostBuilder CreateHostBuilder()
|
||||
|
Loading…
Reference in New Issue
Block a user