Exemple #1
0
        private void ListMessages(User senderUser, User receiverUser)
        {
            SuperChatContext context = new SuperChatContext();

            MessagesListView.Items.Clear();
            var messageList = context.Messages
                              .Where(message => message.RecieverId == receiverUser.Id || message.RecieverId == senderUser.Id)
                              .Where(message => message.SenderId == receiverUser.Id || message.SenderId == senderUser.Id)
                              .OrderBy(message => message.TimeSend).ToList();

            foreach (var message in messageList)
            {
                _symKeyAes.IV   = message.Iv;
                message.Content = SymmetricEncryption.DecryptStringFromBytes_Aes(JsonConvert.DeserializeObject <byte[]>(message.Content), _symKeyAes);
                message.Content = context.Users.Find(message.SenderId).Name + ":\t" + message.Content;
                MessagesListView.Items.Add(message);
            }
        }