//获得用户的未读留言7 OK public List<Message> GetUserUreadPublicMessages(String UserID) { List<Message> PublicMessagesList = new List<Message>(); //数据访存器 DatabaseAccess.DataClasses1DataContext DBAccessor = new DataClasses1DataContext(); try { ISingleResult<getUnreadPublicMessageByUserResult> resultList = DBAccessor.getUnreadPublicMessageByUser(UserID); //获得留言列表 foreach (getUnreadPublicMessageByUserResult result in resultList) { Message message = new Message(); message.ID = result.id; message.messageType = MessageType.publicMessage; message.content = result.content; message.state = MessageState.Unread; //发留言的用户的信息 message.userFrom.UserName = result.userfrom; //发留言户的信息 ISingleResult<getUserByUserNameResult> UserInfoList = DBAccessor.getUserByUserName(result.userfrom); foreach (getUserByUserNameResult UserInfo in UserInfoList) { message.userFrom.NickName = UserInfo.nickname; message.userFrom.Phone = UserInfo.phone; message.userFrom.Address = UserInfo.address; message.userFrom.Email = UserInfo.email; message.userFrom.City = UserInfo.city; message.userFrom.Portrait = UserInfo.portraitPath; } PublicMessagesList.Add(message); } } catch (Exception e) { } return PublicMessagesList; }
//获得用户所有未读的站内信5 Ok public List<Message> GetUserUreadPrivateSiteMessages(String UserID) { List<Message> PrivateSiteMessageList = new List<Message>(); //数据访存器 DatabaseAccess.DataClasses1DataContext DBAccessor = new DataClasses1DataContext(); ISingleResult<getUnreadPrivateMessageByUserResult> resultList = DBAccessor.getUnreadPrivateMessageByUser(UserID); foreach (getUnreadPrivateMessageByUserResult result in resultList) { Message PrivateSiteMessage = new Message(); PrivateSiteMessage.ID = result.id; PrivateSiteMessage.messageType = MessageType.PrivateMessage; PrivateSiteMessage.state = MessageState.Unread; PrivateSiteMessage.content = result.content; PrivateSiteMessage.userFrom.UserName = result.userfrom;//发信用户 //发信用户的信息 ISingleResult<getUserByUserNameResult> UserInfoList = DBAccessor.getUserByUserName(result.userfrom); foreach (getUserByUserNameResult UserInfo in UserInfoList) { PrivateSiteMessage.userFrom.NickName = UserInfo.nickname; PrivateSiteMessage.userFrom.Phone = UserInfo.phone; PrivateSiteMessage.userFrom.Address = UserInfo.address; PrivateSiteMessage.userFrom.Email = UserInfo.email; PrivateSiteMessage.userFrom.City = UserInfo.city; PrivateSiteMessage.userFrom.School = UserInfo.school; PrivateSiteMessage.userFrom.Portrait = UserInfo.portraitPath; } PrivateSiteMessageList.Add(PrivateSiteMessage); } return PrivateSiteMessageList; }