private int GetMyClassesNewNotificationCount() { var list = _uow.QuizzClasses.GetAll() .Where(qc => qc.TeacherId == _currentUser.Id && qc.IsDeleted == false) .ProjectTo <QuizzClassModel>(new { userId = _currentUser.Id }) .ToList(); var count = 0; foreach (var item in list) { item.Member = _uow.QuizzClassMembers.GetAll() .Where(qcm => qcm.Id == item.QuizzClassMemberId) .ProjectTo <QuizzClassMemberModel>() .FirstOrDefault(); count += item.NumStudentJoinRequests; if (item.Member != null) { count += item.Member.NewClassCommentCount; count += item.Member.NewAnnouncementCount; count += item.Member.NewClassQuizzCount; var intArrayHelper = new IntArray(item.Member.NewLessonMessageCount); count += intArrayHelper.GetTotal(); intArrayHelper = new IntArray(item.Member.NewLessonCommentCount); count += intArrayHelper.GetTotal(); intArrayHelper = new IntArray(item.Member.NewLessonQuizzCount); count += intArrayHelper.GetTotal(); } } return(count); }
public void UpdateModel(QuizzClassModel model) { model.IsTeacher = model.TeacherId == _currentUser.Id; model.TeacherName = model.IsTeacherQuizzmate ? model.TeacherFullName : model.TeacherUserName; model.TeacherUserName = ""; model.TeacherFullName = ""; SetAge(model); if (model.LatestAnnouncementPosteDate != null) { model.LatestAnnouncementPosteDate = ((DateTime)model.LatestAnnouncementPosteDate).ToLocalTime(); } var qcAnnouncement = _svcContainer.QuizzClassAnnouncementSvc.GetLatestAnnouncement(model.Id); if (qcAnnouncement != null) { model.LatestAnnouncement = qcAnnouncement.Announcement; model.LatestAnnouncementPosteDate = qcAnnouncement.PostedDate.ToLocalTime(); } model.Member = _uow.QuizzClassMembers.GetAll() .Where(qcm => qcm.Id == model.QuizzClassMemberId) .ProjectTo <QuizzClassMemberModel>() .FirstOrDefault(); if (model.Member != null) { var intArrayHelper = new IntArray(model.Member.NewLessonCommentCount); var totalNewLessonComment = intArrayHelper.GetTotal(); intArrayHelper = new IntArray(model.Member.NewLessonMessageCount); var totalNewLessonContent = intArrayHelper.GetTotal(); intArrayHelper = new IntArray(model.Member.NewLessonQuizzCount); var totalNewQuizzContent = intArrayHelper.GetTotal(); model.NumNewLessonItemCount = model.Member.NewClassLesson + totalNewLessonComment + totalNewLessonContent + totalNewQuizzContent; } }