public void InitializedChatsPage(SavedChats savedChats) { try { if (savedChats.SavedPrivateChats != null) { ChatList = new ObservableCollection <PrivateChat>(savedChats.SavedPrivateChats); } ChatList.Add(new PrivateChat { Name = "Олександр Журба" }); ChatList.Add(new PrivateChat { Name = "Fedir Khydzik" }); ChatList.Add(new PrivateChat { Name = "Olya Ivanenko" }); ChatList.Add(new PrivateChat { Name = "Віталій Пилипенко" }); ChatList.Add(new PrivateChat { Name = "Іван Пилипенко" }); ChatList.Add(new PrivateChat { Name = "Volodya Ivan" }); } catch (Exception) { return; } }
public async Task <SavedChats> GetHistoryChatsAsync(Guid userId) { var firstUserChats = await _chatRepository.Query().Where(r => r.FirstUserInfoId == userId).ToListAsync(); var secondUserChats = await _chatRepository.Query().Where(r => r.SecondUserInfoId == userId).ToListAsync(); var chats = new SavedChats { UserId = userId }; foreach (var value in firstUserChats) { chats.SavedPrivateChats.Add(new PrivateChat { Id = value.Id, Name = value.SecondUserInfo.LastName + " " + value.SecondUserInfo.FirstName, OwnUserId = new Guid(value.FirstUserInfo.Id), UserIdToWrite = new Guid(value.SecondUserInfo.Id) }); } foreach (var value in secondUserChats) { chats.SavedPrivateChats.Add(new PrivateChat { Id = value.Id, Name = value.FirstUserInfo.LastName + " " + value.FirstUserInfo.FirstName, UserIdToWrite = new Guid(value.FirstUserInfo.Id), OwnUserId = new Guid(value.SecondUserInfo.Id) }); } return(chats); }
public ChatPageViewModel(SavedChats savedChats, UsersInfoModel usersInfoModel) { SelectMessageCommand = new DelegateCommand <PrivateChat>(SelectChat); SendNewMessage = new DelegateCommand(SendMessage); Name = usersInfoModel.FullName; _connectionManager = new ConnectionManager(); WriteManId = usersInfoModel.Id; InitializedChatsPage(savedChats); UserID = savedChats.UserId; CurrentChat = savedChats.SavedPrivateChats.SingleOrDefault(chat => chat.UserIdToWrite.ToString() == usersInfoModel.Id); CurrentChat.Messages = new ObservableCollection <ChatMessage>(); }
public ChatPage(SavedChats savedChats, UsersInfoModel usersInfoModel) { InitializeComponent(); DataContext = new ChatPageViewModel(savedChats, usersInfoModel); }
public async Task <SavedChats> HistoryChatsAsync([FromBody] SavedChats input) { return(await _userService.GetHistoryChatsAsync(input.UserId)); }