Esempio n. 1
0
        public void CreateNewPrivateConversation(List <Guid> users)
        {
            MiniProfiler.Current.Step("CreateNewPrivateConversation");
            // If list has duplicates - abort!
            if (users.Count <= 0 || users.Count > 8 || users.Distinct().Count() != users.Count)
            {
                MiniProfiler.Current.Stop();
                return;
            }

            var room = addNewPrivateConversation.Invoke(Context.UserId(), users);

            if (room == null)
            {
                MiniProfiler.Current.Stop();
                return;
            }

            var tempName = StringSeparatorHelper.RemoveUserFromString(Context.UserName(), room.Name);

            Clients.Caller.privateConversationAddedAction(new PrivateConversationViewModel {
                Id = room.Id, Name = tempName
            });
            MiniProfiler.Current.Stop();
        }
Esempio n. 2
0
        public void GetPrivateConversations()
        {
            MiniProfiler.Current.Step("GetPrivateConversations");
            var roomList = getUserPrivateConversations.Invoke(Context.UserId());

            if (roomList != null)
            {
                var viewList = roomList.Select(item => new PrivateConversationViewModel
                {
                    Id   = item.Room.Id,
                    Name = StringSeparatorHelper.RemoveUserFromString(Context.UserName(), item.Room.Name)
                }).ToList();

                Clients.Caller.loadPrivateConversations(viewList);
            }

            MiniProfiler.Current.Stop();
        }