public ActionResult AdminAdminMessages() { if (!Init(User)) { return(RedirectToAction("Index", "Home")); } if ((_isAdministrator && !_permission.Contains(PermissionEnum.CHAT))) { return(RedirectToAction("Menu", "Home")); } List <IGrouping <int, Chat> > threads = _chatRepository.GetAllAdminsForAdmin(_administrator.Id); //List<Chat> lastChat = new List<Chat>(); //foreach (IGrouping<int, Chat> thread in threads) //{ // lastChat.Add(thread.SingleOrDefault(t => t.AddedAt == thread.Max(m => m.AddedAt))); //} //lastChat = lastChat.OrderByDescending(c => c.AddedAt).ToList(); ChatThreadsViewModel model = ChatThreadsViewModel.FromDb(threads, _administrator.Id); model.UserName = GetEmail(); model.ChatRecipient = ChatRecipientEnum.USER; return(View("Index", model)); }
public ActionResult StudentStudentMessages(int page = 1) { if (!Init(User)) { return(RedirectToAction("Index", "Home")); } if (!_isStudent) { return(RedirectToAction("Menu", "Home")); } List <IGrouping <int, Chat> > threads = _chatRepository.GetAllStudentsForStudent(_student.Id); //List<Chat> lastChat = new List<Chat>(); //foreach (IGrouping<int, Chat> thread in threads) //{ // lastChat.Add(thread.SingleOrDefault(t => t.AddedAt == thread.Max(m => m.AddedAt))); //} //lastChat = lastChat.OrderByDescending(c => c.AddedAt).ToList(); ChatThreadsViewModel model = ChatThreadsViewModel.FromDb(threads, studentId: _student.Id); model.UserName = GetEmail(); model.ChatRecipient = ChatRecipientEnum.STUDENT; return(View("Index", model)); }