コード例 #1
0
        public FriendListItem()
        {
            InitializeComponent();

            if (Session.Current.Connected)
            {
                Loaded += (src, e) => {
                    Session.Current.ChatManager.Tick += (src2, e2) => Dispatcher.Invoke(Update);
                    friend = (ChatFriend)DataContext;
                    Update();
                }
            }
            ;
        }
コード例 #2
0
ファイル: ChatHub.cs プロジェクト: mjasiak/MJmail
        public void AddFriend(string friendName)
        {
            ChatFriend      chtFr  = new ChatFriend();
            var             me     = Context.User.Identity.Name;
            ApplicationUser friend = new ApplicationUser();

            using (var _context = new MaildbContext())
            {
                var appUser = _context.Users.First(c => c.Email == me || c.UserName == me);
                friend = _context.Users.First(c => c.Email == friendName || c.UserName == friendName);
                chtFr.ApplicationUser = appUser;
                chtFr.Friend          = friend.Email;
                chtFr.FriendUserName  = friend.UserName;
                _context.ChatFriends.Add(chtFr);
                _context.SaveChanges();
                Clients.Caller.friendsToList(CreateFriendsList(me, _context));
            }
        }