public ContactViewModel(BusinessCoreService businessCoreService, ConversationViewModel conversation) { _businessCoreService = businessCoreService; _conversation = conversation; IsSelected = false; CvsStaff = new CollectionViewSource { Source = _businessCoreService.GetContacts() }; GroupDescription gp = new PropertyGroupDescription("OrganizationId"); SortDescription sp = new SortDescription("OrganizationId", ListSortDirection.Ascending); CvsStaff.GroupDescriptions.Add(gp); CvsStaff.SortDescriptions.Add(sp); CvsStaff.Filter += ApplyFilter; var treeSource = _businessCoreService.GetOrganizationTreeNoChildren(); var data = new ObservableCollection<OrganizationTreeInfoViewModel>(); foreach (var item in treeSource) { data.Add(new OrganizationTreeInfoViewModel(item, _businessCoreService)); } var result = GetOrganizationTree(data.Where(x => x.Info.ParentId == null).ToList(), data); _organizationTreeSource = new ObservableCollection<OrganizationTreeInfoViewModel>(result); OrganizationTreeCvsStaff = new CollectionViewSource { Source = _organizationTreeSource }; Subscription.DoSelectedTree(SelectedUsersCallback); }
public bool AddConversation(string userId, ConversationViewModel conversation) { try { PrivateMessageBoard NewPrivateMsg = new PrivateMessageBoard() { CreateDate = DateTime.Now, Message = conversation.LastMessage, SendFromID = userId, RrecivedFromID = conversation.OtherID }; privateMessageBoardRepo.Insert(NewPrivateMsg); unitOfWork.Commit(); return(true); } catch (EntityException ex) { Debug.WriteLine(ex.Message); return(false); } finally { if (unitOfWork != null) { unitOfWork.Dispose(); } } }
public ActionResult Conversation(SendMessageModel send, ContactModel contact) { if (SessionUtils.IsLogged) { //SendMessageModel send.IdUserFrom = SessionUtils.ConnectedUser.IdUser; string idUserTo = Request.Path.Substring(26); int idUserToInt = int.Parse(idUserTo); send.IdUserTo = idUserToInt; //ContactModel contact.IdUserFrom = SessionUtils.ConnectedUser.IdUser; contact.IdUserTo = idUserToInt; if (ctx.SaveMessage(send)) { ViewBag.SuccessMessage = "Your message has been sent"; List <MessageModel> lm = ctx.GetAllMessage(contact); ConversationViewModel cv = new ConversationViewModel(); cv.ListeMessages = lm; return(View(cv)); } else { ViewBag.ErrorMessage = "Your message has not been sent, try again"; ConversationViewModel cv = new ConversationViewModel(); return(View(cv)); } } else { Session.Abandon(); return(RedirectToAction("Login", "Home", new { area = "" })); } }
public FriendViewModel(IDataService dataService, int friendNumber) { _toxModel = dataService.ToxModel; _avatarManager = dataService.AvatarManager; FriendNumber = friendNumber; Conversation = new ConversationViewModel(dataService, this); FileTransfers = new FileTransfersViewModel(dataService, friendNumber); Call = new CallViewModel(friendNumber); Name = _toxModel.GetFriendName(friendNumber); if (Name == string.Empty) { Name = _toxModel.GetFriendPublicKey(friendNumber).ToString(); } StatusMessage = _toxModel.GetFriendStatusMessage(friendNumber); if (StatusMessage == string.Empty) { StatusMessage = "Friend request sent."; } SetFriendStatus(_toxModel.GetFriendStatus(friendNumber)); IsConnected = _toxModel.IsFriendOnline(friendNumber); _avatarManager.FriendAvatarChanged += FriendAvatarChangedHandler; _toxModel.FriendNameChanged += FriendNameChangedHandler; _toxModel.FriendStatusMessageChanged += FriendStatusMessageChangedHandler; _toxModel.FriendStatusChanged += FriendStatusChangedHandler; _toxModel.FriendConnectionStatusChanged += FriendConnectionStatusChangedHandler; }
public async override void HandleWatchKitExtensionRequest(UIApplication application, NSDictionary userInfo, Action <NSDictionary> reply) { if (userInfo ["Profile"] != null && userInfo ["Profile"].ToString() == "Profile") { var conversationsViewModel = App.ConversationsViewModel; await conversationsViewModel.ExecuteLoadConversationsCommand(); var conversationsList = conversationsViewModel.Conversations.ToList(); ConversationsStore.Save(conversationsList); foreach (var conversation in conversationsList) { var conversationViewModel = new ConversationViewModel(conversation.Sender); await conversationViewModel.ExecuteLoadMessagesCommand(); ConversationsStore.Save(conversationViewModel.Messages.Select(i => i.UnderlyingMessage).ToList(), string.Format("conversation-{0}.xml", conversation.Sender)); } var viewModel = App.ProfileViewModel; NSData avatarImage = !string.IsNullOrEmpty(viewModel.AvatarUrl) ? ImageUtils.GetImage(viewModel.AvatarUrl, url => url == viewModel.AvatarUrl).AsPNG() : new NSData(); reply(new NSDictionary("Username", viewModel.NickName, "Avatar", avatarImage)); } if (userInfo ["TextInput"] != null && userInfo ["TextInput"].ToString() != string.Empty) { var number = userInfo ["SenderID"] as NSNumber; var conversationViewModel = new ConversationViewModel(number.Int32Value); await conversationViewModel.ExecuteLoadMessagesCommand(); await conversationViewModel.SendMessage(userInfo ["TextInput"].ToString()); reply(new NSDictionary("Confirmation", "Text was received")); } }
public static async Task <Conversation> AddConversation(ConversationViewModel model) { await UserService.AddUsers(model.Participants); if (!string.IsNullOrEmpty(model.Creator)) { await UserService.AddUsers(model.Creator); } if (!string.IsNullOrEmpty(model.Owner)) { await UserService.AddUsers(model.Owner); } var conversation = new Conversation { Id = model.Id, Type = model.Type, Creator = UserService.GetUser(model.Creator), Owner = UserService.GetUser(model.Owner), Participants = UserService.Users.Where(u => model.Participants.Contains(u.Nickname)).ToArray() }; switch (model.Type) { case ConversationType.Passive: PassiveConversationService.Conversations.Add(conversation); break; case ConversationType.Active: break; } return(conversation); }
public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new ConversationViewModel(RecipientId); /** * You MUST set your senderId and display name */ SenderId = Settings.MyId.ToString(); SenderDisplayName = Settings.NickName; this.CollectionView.CollectionViewLayout.SpringinessEnabled = false; /** * Load up our fake data for the demo */ CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.MessageBubbleFont = Theme.Current.MessageFont; ShowLoadEarlierMessagesHeader = false; this.InputToolbar.ContentView.TextView.PlaceHolder = "Type a message here"; this.InputToolbar.ContentView.RightBarButtonItem.SetImage(UIImage.FromBundle("sendTextIcon"), UIControlState.Normal); this.InputToolbar.ContentView.RightBarButtonItem.SetTitle("", UIControlState.Normal); this.InputToolbar.ContentView.LeftBarButtonItem = null; /*NavigationItem.RightBarButtonItem = new UIBarButtonItem ( * BubbleImageFromBundleWithName ("typing"), UIBarButtonItemStyle.Bordered, ReceiveMessagePressed);*/ }
public async Task ConversationUpdate(int conversationId) { ConversationViewModel conversation = await this.context.Conversations .Include(x => x.UserConversations) .Select(x => x.ToViewModel()) .SingleOrDefaultAsync(x => x.ConversationId == conversationId); if (conversation == null) { return; } List <string> addressesClientIds = conversation.Addressees .Select(x => x.Id) .ToList(); foreach (var userId in addressesClientIds) { var addresse = this.context.Users .Include(x => x.HubConnections) .SingleOrDefault(x => x.Id == userId); if (addresse != null) { foreach (var connection in addresse.HubConnections) { if (connection.Connected) { await this.Clients.Client(connection.HubConnectionId) .SendAsync("broadcastConversation", conversation); } } } } }
public void AddConversation(string userId, ConversationViewModel conversationModel) { var model = ModelConverters.ToConversationModel(conversationModel); model.ConversationAvatarFilePath = FilePathContainer.ConversationCoversPathRelative + "/DefaultConversation.jpg"; _conversationRepository.AddConversation(userId, model); }
public ActionResult Conversation(ConversationViewModel model) { try { //get conversation data ConversationModel conversation = new ConversationModel(model.ConversationID); if (!ModelState.IsValid) { model.Messages = conversation.Messages; return(View(model)); } //Add message to conversation conversation.AddMessage(model.NewMessageText, model.File); //initiate view model data model = new ConversationViewModel(conversation); return(RedirectToAction("Conversation", "Conversation", model.ConversationID)); } catch (Exception e) { return(RedirectToAction("HandledCodeError", "ErrorHandler", new { exception = e.ToString() })); } }
public async Task <HttpResponseMessage> Conversation(ConversationViewModel conversation) { MitBudDBEntities mitBudDB = new MitBudDBEntities(); var userId = RequestContext.Principal.Identity.GetUserId(); var CompanyEmail = mitBudDB.Companies.Where(x => x.UserId == userId).SingleOrDefault(); //var clientEmail = mitBudDB.Clients.Where(x => x.Client_Id == conversation.Client_id).SingleOrDefault(); var clientId = mitBudDB.Tasks.Where(x => x.TaskId == conversation.TaskID).SingleOrDefault(); //var companyName = CompanyEmail.CompanyName; CompanyProvider.SaveConversation(conversation, userId, clientId.Client_id); var statusCode = HttpStatusCode.Accepted; var responseMsg = new HttpResponseMessage(statusCode) { Content = new StringContent("", Encoding.UTF8, "application/json") }; Email.sendNotificationEmail(clientId.ClientName, clientId.ClientEmail, CompanyEmail.CompanyName); return(responseMsg); }
public void CallMapperService_UsersCountTimes() { // Arrange var mockedMapperService = new Mock <IMapperService>(); var mappedConversation = new ConversationViewModel(); mockedMapperService.Setup(x => x.MapObject <ConversationViewModel>(It.IsAny <Conversation>())).Returns(mappedConversation); var mockedImageService = new Mock <IImageService>(); mockedImageService.Setup(x => x.ByteArrayToImageUrl(It.IsAny <byte[]>())).Returns("some-url"); var mockedUserService = new Mock <IUserService>(); var mockedFriendService = new Mock <IFriendService>(); var viewModelService = new ViewModelService( mockedMapperService.Object, mockedImageService.Object, mockedUserService.Object, mockedFriendService.Object); var conversations = new List <Conversation>() { new Conversation(), new Conversation(), new Conversation() }; // Act viewModelService.GetMappedConversations(conversations); // Assert foreach (var conversation in conversations) { mockedMapperService.Verify(x => x.MapObject <ConversationViewModel>(conversation)); } }
public async Task <IActionResult> Edit(int id, [Bind("Id", "Participant1Id", "Participant2Id", "Timestamp")] ConversationViewModel viewModel) { if (id != viewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var conversation = viewModel.ToConversation(_context); _context.Update(conversation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConversationExists(viewModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(viewModel)); }
private void ReceivedUpdates(List <LongPollServerUpdateData> updates) { List <ConversationViewModel> conversationViewModelList = new List <ConversationViewModel>(); foreach (LongPollServerUpdateData update in updates) { bool isChat = update.isChat; long userOrCharId = isChat ? update.chat_id : update.user_id; if (userOrCharId != 0L) { bool onlyInMemoryCache = update.UpdateType != LongPollServerUpdateType.MessageHasBeenAdded; ConversationViewModel vm = this.GetVM(userOrCharId, isChat, onlyInMemoryCache); if (vm != null) { conversationViewModelList.Add(vm); } } } using (IEnumerator <ConversationViewModel> enumerator = ((IEnumerable <ConversationViewModel>)Enumerable.Distinct <ConversationViewModel>(conversationViewModelList)).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { enumerator.Current.ProcessInstantUpdates(updates); } } }
public async Task <IActionResult> Conversation(String withIdentUserId) { var currentUserId = _userManager.GetUserId(this.User); var conversation = _user.GetConversationBetweenUsers(currentUserId, withIdentUserId); var currentUser = await _userManager.GetUserAsync(User); var model = new ConversationViewModel() { SenderId = currentUserId, ReceiverId = withIdentUserId, SenderUsername = (await _userManager.GetUserAsync(User)).UserName, ReceiverUsername = (await _userManager.FindByIdAsync(withIdentUserId)).UserName, }; var conv = _user.GetConversationBetweenUsers(model.SenderId, model.ReceiverId); model.ConversationId = conv != null ? conv.Id : (int?)null; model.Messages = conv != null?_user.GetConversationMessages(conv.Id, 1, 8) : null; if (model.ConversationId != null && model.ConversationId != 0) { _user.SetConversationRead((int)model.ConversationId); } SetCookieForNotification(currentUserId); return(View(model)); }
public ConversationControl() { InitializeComponent(); Instance = this; model = new ConversationViewModel(null); DataContext = model; }
public void ReturnPartialView_ConversationPartial() { // Arrange var mockedUserService = new Mock <IUserService>(); var mockedViewModelService = new Mock <IViewModelService>(); var model = new ConversationViewModel(); mockedViewModelService.Setup(x => x.GetMappedConversation(It.IsAny <Conversation>())).Returns(model); var mockedFriendService = new Mock <IFriendService>(); var mockedConversationService = new Mock <IConversationService>(); var messageController = new MessageController( mockedUserService.Object, mockedViewModelService.Object, mockedFriendService.Object, mockedConversationService.Object); int id = 4; // Act & Assert messageController .WithCallTo(x => x.Conversation(id)) .ShouldRenderPartialView("_ConversationPartial") .WithModel <ConversationViewModel>(m => { Assert.AreEqual(model, m); }); }
public void CallMapperService_MapObjectOnce() { // Arrange var mockedMapperService = new Mock <IMapperService>(); var mappedConversation = new ConversationViewModel(); mockedMapperService.Setup(x => x.MapObject <ConversationViewModel>(It.IsAny <Conversation>())).Returns(mappedConversation); var mockedImageService = new Mock <IImageService>(); mockedImageService.Setup(x => x.ByteArrayToImageUrl(It.IsAny <byte[]>())).Returns("some-url"); var mockedUserService = new Mock <IUserService>(); var mockedFriendService = new Mock <IFriendService>(); var viewModelService = new ViewModelService( mockedMapperService.Object, mockedImageService.Object, mockedUserService.Object, mockedFriendService.Object); var conversation = new Conversation(); // Act viewModelService.GetMappedConversation(conversation); // Assert mockedMapperService.Verify(x => x.MapObject <ConversationViewModel>(conversation), Times.Once); }
public void ShouldCreateNewCoversationOnSend() { //Arrange: List <PrivateMessageBoard> conversations = new List <PrivateMessageBoard>(); ConversationViewModel conversation = new ConversationViewModel { LastMessage = "Something", OtherID = "OtherID", }; mockPrivateMessageBoardRepo.Setup(x => x.Insert( It.Is <PrivateMessageBoard>(m => m.Message == "Something"))) .Callback(() => conversations.Add(new PrivateMessageBoard { Message = "Something" })); //-----------// //Act: IDogOwnerService dogService = InitializeNewService(); bool isItTrue = dogService.AddConversation(appUser.Id, conversation); //-----------// //Assert: mockPrivateMessageBoardRepo.Verify(mock => mock.Insert( It.IsAny <PrivateMessageBoard>()), Times.Once); mockUnitOfWork.Verify(mock => mock.Commit(), Times.Once); Assert.That(conversations.Count, Is.EqualTo(1)); Assert.That(isItTrue, Is.True); //-----------// }
public ConversationView(FriendModel user) { InitializeComponent(); vm = new ConversationViewModel(Navigation, user); BindingContext = vm; }
public void SetUserIsTypingWithDelayedReset(long userId) { ConversationViewModel conversationViewModel = this._conversationViewModel; if ((conversationViewModel != null ? (!conversationViewModel.IsOnScreen ? 1 : 0) : 0) != 0) { return; } if (this._typingNowUserIds.Contains(userId)) { this.UpdateTypingState(userId, false); } else { DispatcherTimer dispatcherTimer = new DispatcherTimer(); TimeSpan timeSpan = TimeSpan.FromSeconds(5.0); dispatcherTimer.Interval = (timeSpan); DispatcherTimer timer = dispatcherTimer; timer.Tick += ((EventHandler)((o, e) => { timer.Stop(); this.UpdateTypingState(userId, true); })); timer.Start(); this._typingNowUserIds.Insert(0, userId); this._typingNowTimers.Add(userId, timer); this.UpdateTypingView(); } }
public void SetVM(ConversationViewModel conversationVM, bool allowFlush) { if (conversationVM == null) { return; } object lockObj = this._lockObj; bool lockTaken = false; try { Monitor.Enter(lockObj, ref lockTaken); this._inMemoryCachedData[ConversationViewModelCache.GetKey(conversationVM.UserOrCharId, conversationVM.IsChat)] = conversationVM; if (!(this._inMemoryCachedData.Count > this._maxNumberOfInMemoryItems & allowFlush)) { return; } this.FlushToPersistentStorage(); } finally { if (lockTaken) { Monitor.Exit(lockObj); } } }
public async Task PostConversation(ConversationViewModel model) { var data = this.Mapper.Map <Conversation>(model); data.CreateDate = DateTime.Now; await this.AuroraLineBotRepository.PostConversation(data); }
public void AddConversation(ConversationViewModel conversation) { var users = new List <string> { conversation.SenderId, conversation.RecipientId }; _clients.Users(users).addConversation(conversation); }
public ConversationPage(ConversationViewModel model, IInternetConnectionChecker internetConnectionChecker) { InitializeComponent(); _model = model; _internetConnectionChecker = internetConnectionChecker; BindingContext = _model; ((INotifyCollectionChanged)_model.Messages).CollectionChanged += ConversationPage_CollectionChanged; }
public ConversationItems(ConversationViewModel cvm) { this._cvm = cvm; this._cvm.PropertyChanged += new PropertyChangedEventHandler(this._cvm_PropertyChanged); this.Messages = new ObservableCollection <IVirtualizable>(); this.Initialize(); EventAggregator.Current.Subscribe((object)this); }
public PartialViewResult GetChatMessages(string Id) { string algo = string.Empty; ConversationViewModel viewModel = new ConversationViewModel(); viewModel.conversationItems = viewModel.GetConversationById(Id); return(PartialView("_ChatConversation", viewModel)); }
public async Task <bool> RemoveUserToConversationAsync(ConversationViewModel request) { foreach (var participantId in request.ParticipantIds) { var participant = _participantRepository.FindById(participantId); _participantRepository.Delete(participant); } return(await _unitOfWork.SaveChangeAsync() > 0); }
private void OnConversationCreate(Conversation conversation) { var conversationViewModel = new ConversationViewModel { Conversation = conversation }; Dispatcher.Invoke(() => ConversationListView.Items.Add(conversationViewModel)); }
public ScrollManager(ListView messagesListView, ConversationViewModel conversationViewModel, Grid messageAddedNotificationGrid, Storyboard messageAddedNotificationAnimation) { _messagesListView = messagesListView; _conversationViewModel = conversationViewModel; _messageAddedNotificationGrid = messageAddedNotificationGrid; _messageAddedNotificationAnimation = messageAddedNotificationAnimation; _messageAddedNotificationGrid.Visibility = Visibility.Collapsed; }
// GET: Conversation public ActionResult Home() { KindAds.Utils.Enums.Roles rol; rol = (User.IsInRole(KindAds.Utils.Enums.Roles.Publisher.ToString()) ? KindAds.Utils.Enums.Roles.Publisher : KindAds.Utils.Enums.Roles.Advertiser); int rolId = Convert.ToInt32(rol); ConversationViewModel viewModel = new ConversationViewModel(); var email = System.Web.HttpContext.Current.User.Identity.Name; viewModel.conversationItems = viewModel.GetAllConversations(email, rolId); return(View(viewModel)); }
public ConversationViewModel AddConversation(int conversationId, string doctorId, string patientId, string title, string message, int messageType, int category, bool isDelete, DateTimeOffset timestamp) { ConversationViewModel conversation = new ConversationViewModel(); var query = $"EXEC AddConversation '{conversationId}','{doctorId}','{patientId}','{title}','{message}','{messageType}','{category}','{isDelete}','{timestamp}'; "; conversation = _context.ConversationViewModel.FromSql(query).FirstOrDefault(); return(conversation); }
public override void ViewDidLoad () { base.ViewDidLoad (); viewModel = new ConversationViewModel (RecipientId); hiddenInput = new DummyInput(this) { Hidden = true }; View.AddSubview (hiddenInput); SetUpTableView (); SetUpToolbar (); SendButton.TouchUpInside += OnSendClicked; TextView.Changed += OnTextChanged; TextView.Started += OnTextViewStarted; }
public ConversationView(ConversationViewModel vm) { if (vm == null) { throw new ArgumentNullException("vm"); } _viewModel = vm; BuildEmptyView(); IEnumerable<Inline> requestView = MakeRequestView(_viewModel.Request); _view.Inlines.AddRange(requestView); _requestView.AddRange(requestView); vm.PropertyChanged += ((sender, e) => _view.Dispatcher.Invoke((Action)RefreshResponseViews, args: new object[0])); }
//List method - public ConversationViewModel GetConversationData(int conversationId, int familyId, string familyName, string userName) { ConversationViewModel vm = new ConversationViewModel { Conversation = Mapper.Map<ConversationDTO>((from c in _repo.Query<Conversation>() where c.Id == conversationId select c).Include(c => c.MessageList.Select(d => d.Contributor)).FirstOrDefault()), FamilyId = familyId, FamilyName = familyName, UserName = userName }; return (vm); }
public void AddConversation(ConversationViewModel conversation) { var users = new List<string> { conversation.SenderId, conversation.RecipientId }; _clients.Users(users).addConversation(conversation); }
public List<SongViewModel> GetConversationSongs(ConversationViewModel conversation) { var result = new List<SongViewModel>(); if (string.IsNullOrEmpty(conversation.PlaylistId) == false) { var songs = _playlistRepository.GetSongs(conversation.PlaylistId); if (songs != null) { result.AddRange(songs.Select(ModelConverters.ToSongViewModel)); } } return result; }
public void RemoveConversation(string userId, ConversationViewModel conversationViewModel) { _conversationRepository.RemoveConversation(userId, ModelConverters.ToConversationModel(conversationViewModel)); }
public async override void HandleWatchKitExtensionRequest (UIApplication application, NSDictionary userInfo, Action<NSDictionary> reply) { if (userInfo ["Profile"] != null && userInfo ["Profile"].ToString () == "Profile") { var conversationsViewModel = App.ConversationsViewModel; await conversationsViewModel.ExecuteLoadConversationsCommand (); var conversationsList = conversationsViewModel.Conversations.ToList (); ConversationsStore.Save (conversationsList); foreach (var conversation in conversationsList) { var conversationViewModel = new ConversationViewModel (conversation.Sender); await conversationViewModel.ExecuteLoadMessagesCommand (); ConversationsStore.Save (conversationViewModel.Messages.Select(i => i.UnderlyingMessage).ToList (), string.Format ("conversation-{0}.xml", conversation.Sender)); } var viewModel = App.ProfileViewModel; NSData avatarImage = !string.IsNullOrEmpty (viewModel.AvatarUrl) ? ImageUtils.GetImage (viewModel.AvatarUrl, url => url == viewModel.AvatarUrl).AsPNG () : new NSData (); reply (new NSDictionary ("Username", viewModel.NickName, "Avatar", avatarImage)); } if (userInfo ["TextInput"] != null && userInfo ["TextInput"].ToString () != string.Empty) { var number = userInfo ["SenderID"] as NSNumber; var conversationViewModel = new ConversationViewModel (number.Int32Value); await conversationViewModel.ExecuteLoadMessagesCommand (); await conversationViewModel.SendMessage (userInfo ["TextInput"].ToString ()); reply (new NSDictionary ("Confirmation", "Text was received")); } }
public ChatSource(ConversationViewModel viewModel) { this.viewModel = viewModel; sizingCells = new BubbleCell[2]; }
public List<MessageViewModel> GetConversationMessages(ConversationViewModel conversationViewModel, string userId) { var messages = _conversationRepository.GetConversationMessages(userId, ModelConverters.ToConversationModel(conversationViewModel)); var resultList = new List<MessageViewModel>(); resultList.AddRange(messages.Select(ModelConverters.ToMessageViewModel)); foreach (var message in resultList) { message.MessageSongs = new List<SongViewModel>(); var songs = _conversationRepository.GetMessageSongs(message.MessageId); message.MessageSongs.AddRange(songs.Select(ModelConverters.ToSongViewModel)); } return resultList; }