public void Setup()
 {
     userNames = new List <string>()
     {
         "name1", "name2", "name3", "name4"
     };
     viewModel = new ConversationListViewModel(-1, "last message", userNames);
 }
Example #2
0
        public async Task <IActionResult> GetAllConversationsByAdId(int id)
        {
            ConversationListViewModel model = new ConversationListViewModel();

            model.UserId        = _userManager.GetUserId(User);
            model.Conversations = await _conversationService.GetAllConversationByAdId(id);

            return(View("Conversations", model));
        }
        public async Task <IActionResult> GetAllMessages()
        {
            ConversationListViewModel model = new ConversationListViewModel();
            var user = await _userManager.GetUserAsync(User);

            model.Conversations = await _conversationService.GetAllConverastionBySenderId(user.Id);

            model.UserId = user.Id;
            return(View("Conversations", model));
        }
        public async Task <IActionResult> GetConversations()
        {
            var conversations = new ConversationListViewModel
            {
                Conversations = await _db.Conversations
                                .Select(ConversationListViewMapping.MapConversationViewModel())
                                .ToListAsync()
            };

            return(Ok(conversations));
        }
        public ConversationList()
        {
            InitializeComponent();

            BindingContext = new ConversationListViewModel(Navigation);
            ConversationListItems.ItemTapped += (sender, args) =>
            {
                Conversation conversation = (Conversation)args.Item;
                Navigation.PushAsync(new ConversationDetail(conversation.Id));
            };
        }
        public ConversationPage()
        {
            InitializeComponent();

            ListView listView = (ListView)list;

            convos = new ObservableCollection <ConversationListViewModel>();
            listView.ItemsSource = convos;
            listView.ItemTapped += (sender, e) =>
            {
                ConversationListViewModel selected = (ConversationListViewModel)e.Item;
                Navigation.PushAsync(new MasterMessagePage(selected.ConversationId));
                ((ListView)sender).SelectedItem = null;
            };

            this.UpdateConversations();
        }
Example #7
0
        private static ConversationListViewModel GetConversation(ApiCentralPrivateChatMessageModel chatMessageModel, ApiWhitelabelPublicUserModel userModel)
        {
            if (chatMessageModel == null)
            {
                return(null);
            }

            // Conversation id is always the other user's id
            var conversation = new ConversationListViewModel
            {
                Id                  = userModel.Id,
                DisplayName         = userModel.DisplayName,
                UserId              = userModel.Id,
                AvatarUrl           = userModel.Avatar?.Small,
                FromMe              = userModel.Id == Settings.UserId,
                IsRead              = chatMessageModel.IsRead,
                LastMessage         = chatMessageModel.Text,
                LastMessageDateTime = chatMessageModel.DateTime,
            };

            return(conversation);
        }