/// <summary>
 /// 通过发送方获取消息列表
 /// </summary>
 /// <param name="userDTO">发送方</param>
 /// <returns>消息列表</returns>
 public IEnumerable<MessageDTO> GetMessagesBySendUser(UserDTO sendUserDTO)
 {
     //User user = userRepository.GetUserByName(sendUserDTO.Name);
     var messages = messageService.GetMessagesBySendUser(Mapper.Map<UserDTO, User>(sendUserDTO));
     if (messages == null)
         return null;
     var ret = new List<MessageDTO>();
     foreach (var message in messages)
     {
         ret.Add(Mapper.Map<Message, MessageDTO>(message));
     }
     return ret;
 }
 public void MessageApplication()
 {
     IMessageService messageService = new MessageServiceImpl(new MessageDomainService(
             new MessageRepository(new EntityFrameworkRepositoryContext()),
             new UserRepository(new EntityFrameworkRepositoryContext())));
     UserDTO userDTO = new UserDTO
     {
         Name = "小菜"
     };
     var messages = messageService.GetMessagesBySendUser(userDTO);
     foreach (MessageDTO item in messages)
     {
         Console.WriteLine(item.Title);
     }
 }
 public int GetNoReadCount(string userName)
 {
     UserDTO userDTO = new UserDTO { Name = userName };
     return messageServiceImpl.GetNoReadCount(userDTO);
 }
 public IEnumerable<MessageDTO> GetMessagesBySendUser(string userName)
 {
     UserDTO userDTO = new UserDTO { Name = userName };
     var messages = messageServiceImpl.GetMessagesBySendUser(userDTO);
     return messages;
 }
 /// <summary>
 /// 查看消息
 /// </summary>
 /// <param name="ID"></param>
 /// <returns></returns>
 public MessageDTO ShowMessage(string id, UserDTO currentUserDTO)
 {
     Message message = messageService.ShowMessage(id, Mapper.Map<UserDTO, User>(currentUserDTO));
     return Mapper.Map<Message, MessageDTO>(message);
 }
 /// <summary>
 /// 获取未读消息数
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public int GetNoReadCount(UserDTO userDTO)
 {
     return messageService.GetNoReadCount(Mapper.Map<UserDTO, User>(userDTO));
 }