public ActionResult Index(long? openedChat) { IndexMessagesViewResult result = new IndexMessagesViewResult(); Profile myProfile = ProfileRepository.GetProfile(user.ProfileId); result.Profile = myProfile; var DialogProfile = MessageRepository.GetMyDialogs(myProfile.ProfileId); result.Dialogs = new List<DialogInfo>(); foreach (var profile in DialogProfile) { DialogInfo dialogInfo = new Models.DialogInfo(); dialogInfo.Profile = profile; dialogInfo.LastUpdate = MessageRepository.GetDialogLastMessageTime(profile.ProfileId, myProfile.ProfileId); dialogInfo.NewMessages = MessageRepository.GetDialogNewMessagesCount(profile.ProfileId, myProfile.ProfileId); result.Dialogs.Add(dialogInfo); } var lastDialog = DialogProfile.FirstOrDefault(); result.openedChat = (openedChat != null && openedChat != myProfile.ProfileId && ProfileRepository.IsProfileExists(openedChat) ? (long)openedChat : lastDialog != null ? lastDialog.ProfileId : 0); return View(result); }
public ActionResult Index(long?openedChat) { IndexMessagesViewResult result = new IndexMessagesViewResult(); var myProfile = ProfileRepository.GetProfile(user.ProfileId); result.Profile = myProfile; var DialogProfile = MessageRepository.GetMyDialogs(myProfile.ProfileId); result.Dialogs = new List <DialogInfo>(); foreach (var profile in DialogProfile) { DialogInfo dialogInfo = new Models.DialogInfo(); dialogInfo.Profile = profile; dialogInfo.LastUpdate = MessageRepository.GetDialogLastMessageTime(profile.ProfileId, myProfile.ProfileId); dialogInfo.NewMessages = MessageRepository.GetDialogNewMessagesCount(profile.ProfileId, myProfile.ProfileId); result.Dialogs.Add(dialogInfo); } var lastDialog = DialogProfile.FirstOrDefault(); result.openedChat = (openedChat != null && openedChat != myProfile.ProfileId && ProfileRepository.IsProfileExists(openedChat) ? (long)openedChat : lastDialog != null ? lastDialog.ProfileId : 0); return(View(result)); }
public ActionResult UnreadMessagesShort() { Profile myProfile = ProfileRepository.GetProfile(user.ProfileId); UnreadMessagesShortResult result=new UnreadMessagesShortResult(); var DialogProfile = MessageRepository.GetMyDialogs(myProfile.ProfileId); result.Dialogs = new List<DialogInfo>(); foreach (var profile in DialogProfile) { DialogInfo dialogInfo = new Models.DialogInfo(); dialogInfo.Profile = profile; dialogInfo.LastUpdate = MessageRepository.GetDialogLastMessageTime(profile.ProfileId, myProfile.ProfileId); dialogInfo.NewMessages = MessageRepository.GetDialogNewMessagesCount(profile.ProfileId, myProfile.ProfileId); var lastmessage = MessageRepository.GetDialog(profile.ProfileId, myProfile.ProfileId, 1).Where(m => m.ProfileIdTo == myProfile.ProfileId && ((m.Read == false) || (m.Read == null))).FirstOrDefault(); if (lastmessage != null) { dialogInfo.LastMessage = lastmessage.MessageText; result.Dialogs.Add(dialogInfo); } } return PartialView(result); }
public ActionResult UnreadMessagesShort() { var myProfile = ProfileRepository.GetProfile(user.ProfileId); UnreadMessagesShortResult result = new UnreadMessagesShortResult(); var DialogProfile = MessageRepository.GetMyDialogs(myProfile.ProfileId); result.Dialogs = new List <DialogInfo>(); foreach (var profile in DialogProfile) { DialogInfo dialogInfo = new Models.DialogInfo(); dialogInfo.Profile = profile; dialogInfo.LastUpdate = MessageRepository.GetDialogLastMessageTime(profile.ProfileId, myProfile.ProfileId); dialogInfo.NewMessages = MessageRepository.GetDialogNewMessagesCount(profile.ProfileId, myProfile.ProfileId); var lastmessage = MessageRepository.GetDialog(profile.ProfileId, myProfile.ProfileId, 1).Where(m => m.ProfileIdTo == myProfile.ProfileId && ((m.Read == false) || (m.Read == null))).FirstOrDefault(); if (lastmessage != null) { dialogInfo.LastMessage = lastmessage.MessageText; result.Dialogs.Add(dialogInfo); } } return(PartialView(result)); }