Exemple #1
0
        public void AddGroup(string name, int userId)
        {
            var chatGroupEntity    = _db.DbAccess.AddChatGroup(name);
            var chatGroupViewModel = new ChatGroupViewModel(chatGroupEntity);

            ChatGroups.Add(chatGroupViewModel);
            AddUserToGroup(chatGroupEntity.ChatGroupId, userId);
        }
Exemple #2
0
        public ChatService()
        {
            _db             = IoC.Resolve <DbEntities>();
            ChatGroups      = new ObservableCollection <ChatGroupViewModel>();
            CollectionViews = new ConcurrentDictionary <int, ICollectionView>();
            var users = _db.DbAccess.GetUsers();

            foreach (var chatGroupEntity in _db.DbAccess.GetChatGroups())
            {
                var chatGroupViewModel = new ChatGroupViewModel(chatGroupEntity);
                ChatGroups.Add(chatGroupViewModel);

                foreach (var dbAccessChatMessage in _db.DbAccess.GetChatMessages(chatGroupViewModel.Entity.ChatGroupId))
                {
                    chatGroupViewModel.Messages.Add(new ChatMessageEntityViewModel()
                    {
                        Entity = dbAccessChatMessage,
                        User   = users.FirstOrDefault(e => e.AppUserId == dbAccessChatMessage.IdUser)
                    });
                }
            }
        }