Exemple #1
0
        public AddUserViewModel(IUserAccountService userAccountService, IChatRoomDataService chatRoomDataService)
        {
            _userAccountService  = userAccountService;
            _chatRoomDataService = chatRoomDataService;

            SearchForUsersCommand = new RelayCommand <string>(async(username) => await SearchForUsers(username));
            AddUserCommand        = new RelayCommand <User>(AddUser);
        }
Exemple #2
0
 ///  <summary>
 ///         Chat room controller constructor.
 ///  </summary>
 ///  <param name="chatRoomDataService"> Injected data service for chat rooms. </param>
 ///  <param name="mapper"> Injected AutoMapper. </param>
 ///  <param name="exchangeService"> Service for managing connection queue's. </param>
 ///  <param name="messageService"> Service for sending rabbitmq messages. </param>
 public ChatRoomController(IChatRoomDataService chatRoomDataService,
                           IMapper mapper,
                           IExchangeService exchangeService,
                           IMessageService messageService)
 {
     _chatRoomDataService = chatRoomDataService;
     _mapper          = mapper;
     _exchangeService = exchangeService;
     _messageService  = messageService;
 }
Exemple #3
0
        public AddChatRoomViewModel(IChatRoomDataService chatRoomDataService)
        {
            _chatRoomDataService = chatRoomDataService;
            // initialize chat room
            ChatRoomModel = new ChatRoom()
            {
                Users = new List <User>()
                {
                    UserInstance.Current
                },
                ChatMessages = new List <ChatMessage>()
            };

            // initialize commands
            SubmitCommand = new RelayCommand(Submit, true);
        }
Exemple #4
0
        public MainViewModel(IChatRoomDataService chatRoomDataService, INavigationService navigationService, IQueueService queueService)
        {
            _chatRoomDataService = chatRoomDataService;
            _navigationService   = navigationService;
            _queueService        = queueService;

            ToggleAddChatRoomControlVisibilityCommand = new RelayCommand(ToggleAddChatRoomVisibility, true);
            ShowUserProfileCommand = new RelayCommand(ShowUserProfileControl);

            AddChatRoomViewModel = new AddChatRoomViewModel(chatRoomDataService);

            MessengerInstance.Register <NotificationMessage <string> >(this, action => HandleStringMessage(action.Notification));
            MessengerInstance.Register <NotificationMessage <ChatRoom> >(this, action => HandleChatRoomMessage(action.Content, action.Notification));

            SetupMessageBrokerListener();
        }
Exemple #5
0
        ///  <summary>
        ///         Constructs a chat room view model.
        ///  </summary>
        ///  <param name="id"> Id of the chat room. </param>
        ///  <param name="chatMessageDataService"> Service for managing chat message data. </param>
        ///  <param name="chatRoomDataService"> Service for managing chat room data. </param>
        public ChatRoomViewModel(int id, IChatMessageDataService chatMessageDataService, IChatRoomDataService chatRoomDataService)
        {
            _chatMessageDataService = chatMessageDataService;
            _chatRoomDataService    = chatRoomDataService;

            Id = id;

            // commands
            SendMessageCommand          = new RelayCommand(SendMessage, () => !string.IsNullOrEmpty(UserText));
            DeleteMessageCommand        = new RelayCommand <ChatMessage>(DeleteMessage, (messageToDelete) => messageToDelete?.User?.Id == UserInstance.Current?.Id);
            ToggleAddUserControlCommand = new RelayCommand(ToggleAddUserControl);
            DeleteChatRoomCommand       = new RelayCommand(DeleteChatRoom);

            // view models
            AddUserViewModel = new AddUserViewModel(SimpleIoc.Default.GetInstance <IUserAccountService>(), SimpleIoc.Default.GetInstance <IChatRoomDataService>())
            {
                ChatRoomId = id
            };

            // view model message listeners
            MessengerInstance.Register <NotificationMessage <ChatMessage> >(this, id, action => HandleChatMessageNotification(action.Content, action.Notification));
            MessengerInstance.Register <NotificationMessage <User> >(this, id, action => HandleUserNotification(action.Content, action.Notification));
        }