public static void CreateMessage(Message message)
 {
     using (ChatContext context = new ChatContext())
     {
         context.Messages.Add(message);
         context.SaveChanges();
     }
 }
        public static void AddMessage(string channelName, string senderNickname, string messageText)
        {
            ValidateChannelName(channelName);
            ValidateNickname(senderNickname);
            using (ChatContext context = new ChatContext())
            {
                Message currentMsg = new Message()
                {
                    Author = senderNickname,
                    Content = messageText,
                    DateTime = DateTime.Now,
                };

                var dbChannel = context.Channels.FirstOrDefault(c => c.Name.ToLower() == channelName.ToLower());
                dbChannel.History.Add(currentMsg);

                context.SaveChanges();
            }
        }