public override void AddMessage(DateTime time, List<int> users, int author, string message)
        {
            using (DataEntities ctx = new DataEntities())
            {
                if (ctx.users.FirstOrDefault(u => u.user_id == author) == null)
                {
                    throw new UserNotExistingException();
                }
                foreach (int id in users)
                {
                    if (ctx.users.FirstOrDefault(u => u.user_id == id) == null)
                    {
                        throw new UserNotExistingException();
                    }
                }

                message msg = new message
                {
                    author_id = author,
                    time = time,
                    message1 = message
                };

                foreach (int id in users)
                {
                    msg.users.Add(ctx.users.FirstOrDefault(u => u.user_id == id));
                }

                ctx.messages.Add(msg);
                ctx.SaveChanges();
            }
        }
 private Message Convert(message m)
 {
     return new Message(m.message_id, m.time, m.users.Select(u => u.user_id).ToList(), m.author_id, m.message1);
 }