еще фиксы

This commit is contained in:
gg12 darfren 2024-04-08 23:45:46 +04:00
parent bdd4869d77
commit c21b7fe216
2 changed files with 19 additions and 6 deletions

View File

@ -73,12 +73,22 @@ namespace SchoolSchedule
} }
try try
{ {
StudentBindingModel model = new StudentBindingModel StudentBindingModel model;
{ if( _id.HasValue)
Id = (_id.HasValue ? _id.Value : 0), model =new StudentBindingModel
FullName = textBox1.Text, {
GradeId = Convert.ToInt32(comboBox1.SelectedValue), Id = (_id.HasValue ? _id.Value : 0),
}; FullName = textBox1.Text,
GradeId = Convert.ToInt32(comboBox1.SelectedValue),
Attendance = _logicS.ReadElement(new StudentSearchModel { Id = _id.Value}).Attendance
};
else
model = new StudentBindingModel
{
Id = (_id.HasValue ? _id.Value : 0),
FullName = textBox1.Text,
GradeId = Convert.ToInt32(comboBox1.SelectedValue),
};
var operationResult = (_id.HasValue ? _logicS.Update(model) : _logicS.Create(model)); var operationResult = (_id.HasValue ? _logicS.Update(model) : _logicS.Create(model));
if (!operationResult) if (!operationResult)
{ {

View File

@ -80,8 +80,11 @@ namespace SchoolScheduleDataBaseImplement.Models
context.SaveChanges(); context.SaveChanges();
foreach (var updateComponent in attendance) foreach (var updateComponent in attendance)
{ {
updateComponent.Status = model.Attendance[updateComponent.LessonId].Item2;
updateComponent.Mark = model.Attendance[updateComponent.LessonId].Item3;
model.Attendance.Remove(updateComponent.LessonId); model.Attendance.Remove(updateComponent.LessonId);
} }
context.SaveChanges();
} }
var student = context.Students.First(x => x.Id == Id); var student = context.Students.First(x => x.Id == Id);
foreach (var pc in model.Attendance) foreach (var pc in model.Attendance)