예제 #1
0
        public void AddChatMessage(Guid chatRoomId, ChatMessageText chatMessageText)
        {
            ChatRoom chatRoom = _chatRoomRepository
                                .Get(new ChatRoomSpecification(chatRoomId))
                                .FirstOrDefault();

            if (chatRoom != default(ChatRoom))
            {
                chatRoom.AddMessage(chatMessageText);
                _chatRoomRepository.Update(chatRoom);
            }
            _logger.LogInformation($"Chat room with id {chatRoomId.ToString()} not found.", null);
        }
예제 #2
0
 public void AddChatMessageBelowBoundaries()
 {
     this.chatRoom.ClearMessages();
     chatRoom.AddMessage(new ChatMessageText(Guid.NewGuid(), "Hello!"));
     (bool result, string message) = chatRoom.AddMessage(new ChatMessageText(Guid.NewGuid(), "Hello!"));
     Assert.AreEqual(true, result);
     Assert.AreEqual(string.Empty, message);
 }
예제 #3
0
        void Handle_SendMessage(object sender, System.EventArgs e)
        {
            if (!(BindingContext is MainPageViewModel vm))
            {
                return;
            }

            try {
                var m = currentRoom?.AddMessage(vm.Username, vm.NewMessage);
                vm.NewMessage = "";
                vm.Error      = null;
                newMessage.Focus();
            }
            catch (Exception ex) {
                vm.Error = ex;
            }
        }