public async Task <IEnumerable <MarkDto> > GetTotalMarksForGroupByLessonId(int groupId, int lessonId, DateTime startDate, DateTime endDate) { var marks = await _repository.FilterAsync(x => x.SubjectId == lessonId && x.Student.GroupId == groupId && x.Date >= startDate && x.Date <= endDate); return(marks.GroupBy(x => x.StudentId).Select(x => new MarkDto { LessonId = lessonId, StudentId = x.Key, Mark = x.Sum(m => m.Grade), MarkDate = endDate })); }