/// <summary>
        /// Добавляет преподавателя к журналу
        /// </summary>
        /// <param name="elGradebookTeacher"></param>
        /// <returns></returns>
        public async Task AddElGradebookTeacher(ElGradebookTeacher elGradebookTeacher)
        {
            if (elGradebookTeacher == null)
            {
                throw new NullReferenceException();
            }

            if (string.IsNullOrEmpty(elGradebookTeacher.TeacherFio))
            {
                var appUser = await _context.Users.FirstOrDefaultAsync(u => u.Id == elGradebookTeacher.UserId);

                if (appUser == null)
                {
                    throw new NullReferenceException($"Пользователь {elGradebookTeacher.UserId} не найден!");
                }
                elGradebookTeacher.TeacherFio = appUser.GetFullName;
            }

            var elGradebook = await GetElGradebookAsync(elGradebookTeacher.ElGradebookId);

            var cmp = new ElGradebookTeacherComparer();

            if (elGradebook.ElGradebookTeachers.Contains(elGradebookTeacher, cmp))
            {
                return;
            }

            _context.Add(elGradebookTeacher);
            await _context.SaveChangesAsync();
        }
        /// <summary>
        /// Возвращает список журналов пользователя согласно параметрам фильтра
        /// </summary>
        /// <param name="filterAndSortModel"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public async Task <List <ElGradebook> > GetElGradebooks(ElGradebooksFilterAndSortModel filterAndSortModel, string userName)
        {
            if (userName == null)
            {
                return(null);
            }

            var appUser = await GetAppUserAsync(userName);

            if (appUser == null)
            {
                return(null);
            }

            var query = GetElGradebooks(filterAndSortModel);

            var cmp = new ElGradebookTeacherComparer();
            var st  = new ElGradebookTeacher();

            st.UserId = appUser.Id;

            query = query.Where(g => g.ElGradebookTeachers.Contains(st, cmp));
            query = query.OrderByDescending(g => g.GroupName);

            var result = query.ToList();

            return(result);
        }