public ActionResult Details(long messageID, int?pageIndex) { pageIndex = pageIndex ?? 1; UserMessageRepository.LoadWith(x => x.CreatorUser, x => x.MessageSection); var message = UserMessageRepository.GetByPK(messageID); if (message == null || message.ReceiverUserID.HasValue) { return(null); } var studentIds = _.List(message.CreatorUser.Student_ID.GetValueOrDefault()); var userMessages = UserMessageRepository.GetAll(x => x.ParentMessageID == messageID) .OrderBy(x => x.UserMessageID) .ToPagedList(pageIndex.Value - 1); studentIds.AddRange(userMessages.Select(x => x.CreatorUser.Student_ID.GetValueOrDefault())); studentIds = studentIds.Where(x => x > 0).ToList(); /* var bestStudents = ProfileService.FilterBestGraduate(studentIds); * var excelMasterStudents = ProfileService.FilterExcelMaster(studentIds);*/ var realStudents = ProfileService.FilterRealGraduate(studentIds); var model = new MessageVM { Message = message, Answers = userMessages }; model.AllMessages.ForEach(x => { var studentId = x.CreatorUser.Student_ID.GetValueOrDefault(); if (studentId > 0) { var types = new List <string>(); /* if(bestStudents.Contains(studentId)) { * types.Add(UserMessage.BestGraduate); * } * if(excelMasterStudents.Contains(studentId)) { * types.Add(UserMessage.ExcelMaster); * }*/ var real = realStudents.GetValueOrDefault(studentId); if (real != null) { types.Add(UserMessage.RealSpecialist + real); } x.BestTypes = types; } }); return(View(model)); }