Exemple #1
0
        public IEnumerable <ChatMessage> GetLastFiveChatMessages()
        {
            //get all messages
            Account account = (Account)Session["loggedin_account"];
            IEnumerable <ChatMessage> old2chatmessages = chatRepository.GetAllChatMessages(account.Id);
            //ienumerable to list zodat ik ze kan sorteren
            List <ChatMessage> oldmessages = old2chatmessages.ToList();
            List <ChatMessage> newmessages = new List <ChatMessage>();
            int counti = oldmessages.Count;

            if (counti > 5)
            {
                for (int i = 1; i <= 5; i++)
                {
                    newmessages.Add(oldmessages[counti - i]);
                }
                return(newmessages);
            }
            else
            {
                for (int i = 1; i <= counti; i++)
                {
                    newmessages.Add(oldmessages[counti - i]);
                }
                return(newmessages);
            }
        }
Exemple #2
0
        private async Task <string> GetChatMessageInternal()
        {
            var ChatMessages = await _chatMessageRepository.GetAllChatMessages();

            return(JsonConvert.SerializeObject(ChatMessages));
        }