/// <summary> /// Добавление учебного занятия в журнал /// </summary> /// <param name="elGradebook"></param> /// <returns></returns> public async Task AddElGradebookLessonAsync(ElGradebookLesson elGradebook) { if (elGradebook == null) { throw new ArgumentNullException(); } if (elGradebook.ElGradebookId == 0) { throw new Exception("Не указан УИД электронного журнала!"); } _context.Add(elGradebook); await _context.SaveChangesAsync(); }
/// <summary> /// Добавление в занятие электронного журнала списка студентов /// </summary> /// <param name="elGradebookLesson"></param> /// <param name="elGradebookGroupStudents"></param> /// <returns></returns> public async Task AddElGradebookLessonMarksAsync(ElGradebookLesson elGradebookLesson, List <ElGradebookGroupStudent> elGradebookGroupStudents) { foreach (var student in elGradebookGroupStudents) { elGradebookLesson.ElGradebookLessonMarks.Add( new ElGradebookLessonMark { ElGradebookGroupStudentId = student.ElGradebookGroupStudentId, ElGradebookLessonAttendanceTypeId = 1 } ); } await _context.SaveChangesAsync(); }
/// <summary> /// Обновляет учебное занятие /// </summary> /// <param name="elGradebookLesson"></param> /// <returns></returns> public async Task UpdateElGradebookLessonAsync(ElGradebookLesson elGradebookLesson) { if (elGradebookLesson == null) { throw new Exception("elGradebookLesson = null"); } var entry = await GetElGradebookLessonAsync(elGradebookLesson.ElGradebookLessonId); if (entry == null) { throw new KeyNotFoundException($"Объект типа ElGradebookLesson с ElGradebookLessonId = {elGradebookLesson.ElGradebookLessonId} не найден!"); } if (entry.Date != elGradebookLesson.Date) { entry.Date = elGradebookLesson.Date; } if (entry.ElGradebookLessonTypeId != elGradebookLesson.ElGradebookLessonTypeId) { entry.ElGradebookLessonTypeId = elGradebookLesson.ElGradebookLessonTypeId; } if (entry.HoursNumber != elGradebookLesson.HoursNumber) { entry.HoursNumber = elGradebookLesson.HoursNumber; } if (entry.LessonTheme != elGradebookLesson.LessonTheme) { entry.LessonTheme = elGradebookLesson.LessonTheme; } await _context.SaveChangesAsync(); }
/// <summary> /// Удаление учебного занятия из журнала /// </summary> /// <param name="elGradebookLesson"></param> /// <returns></returns> public async Task RemoveElGradebookLessonAsync(ElGradebookLesson elGradebookLesson) { _context.Remove(elGradebookLesson); await _context.SaveChangesAsync(); }