Ejemplo n.º 1
0
        public virtual Message AddMessage(Author author, Message message)
        {
            message.Author = author;
            message.ParentMessage = this;
            message.NrOrder = Messages.Count() + 1;
            Messages.Add(message);

            author.Messages.Add(message);
            return message;
        }
Ejemplo n.º 2
0
 public virtual Author AddLike(Author author)
 {
     Likes.Add(author);
     return author;
 }
Ejemplo n.º 3
0
 private static Message AddMessage(Author author, Message msg, string text, DateTime createdOn)
 {
     return msg.AddMessage(author, new Message() { Text = text, CreatedOn = createdOn });
 }
Ejemplo n.º 4
0
        public static void Generate()
        {
            // create our NHibernate session factory
            var sessionFactory = CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                // populate the database
                using (var transaction = session.BeginTransaction())
                {
                    var commonPassword = "******";
                    var leonard = new Author { Login = "******", Password = commonPassword, Name = "Leonard Hofstadter" };
                    var sheldon = new Author { Login = "******", Password = commonPassword, Name = "Sheldon Cooper" };
                    var raj = new Author { Login = "******", Password = commonPassword, Name = "Rajesh Koothrappali" };
                    var howard = new Author { Login = "******", Password = commonPassword, Name = "Howard Wollowitz" };
                    var penny = new Author { Login = "******", Password = commonPassword, Name = "Penny" };

                    AddAuthors(session, leonard, sheldon, raj, howard, penny);

                    //AddMessageToAuthor();
                    var author = raj;

                    var time = DateTime.Now.Add(new TimeSpan(-40, 0, 0));
                    var msg = AddMessage(author, "raj (Entering dressed as Thor): Hey. Sorry I’m late, but my hammer got stuck in the door on the bus.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "You went with Thor?", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(raj, msg, "What? Just because I’m Indian I can’t be a Norse God? No, no, no, Raj has to be an Indian God. That’s racism. I mean, look at Wolowitz, he’s not English, but he’s dressed like Peter Pan. Sheldon(entering in a body suit featuring black and white vertical lines) is neither sound nor light, but he’s obviously the Doppler Effect.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(howard, msg, "I’m not Peter Pan, I’m Robin Hood.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(raj, msg, "Really, because I saw Peter Pan, and you’re dressed exactly like Cathy Rigby. She was a little bigger than you, but it’s basically the same look, man.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "Hey, Sheldon, there’s something I want to talk to you about before we go to the party.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "I don’t care if anybody gets it, I’m going as the Doppler Effect.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "No, it’s not…", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "If I have to, I can demonstrate. Neeeeoooowwwww!", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "Terrific. Um, this party is my first chance for Penny to see me in the context of her social group, and I need you not to embarrass me tonight.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "Well, what exactly do you mean by embarrass you?", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "For example, tonight no-one needs to know that my middle name is Leakey.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "Well, there’s nothing embarrassing about that, your father worked with Lewis Leakey, a great anthropologist. It had nothing to do with your bed-wetting.", time);
                    time = time.Add(new TimeSpan(0, 149, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "All I’m saying is that this party is the perfect opportunity for Penny to see me as a member of her peer group. A potential close friend and… perhaps more. I don’t want to look like a dork.", time);
                    session.SaveOrUpdate(msg);

                    time = DateTime.Now.Add(new TimeSpan(-1, 0, 0));
                    msg = AddMessage(author, "Water Demon.", time);
                    time = time.Add(new TimeSpan(0, 2, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(howard, msg, "Ice Dragon.", time);
                    time = time.Add(new TimeSpan(0, 3, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "Lesser Warlord of Ka’a.", time);
                    time = time.Add(new TimeSpan(0, 1, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "Not so fast. Infinite Sheldon.", time);
                    time = time.Add(new TimeSpan(0, 7, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "Infinite Sheldon?", time);
                    //time = time.Add(new TimeSpan(0, 2, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "Yes, Infinite Sheldon defeats all other cards and does not violate the rule against homemade cards because I made it at work.", time);
                    //time = time.Add(new TimeSpan(0, 2, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(leonard, msg, "Do you understand why people don’t want to play with you?", time);
                    //time = time.Add(new TimeSpan(0, 1, 0));
                    session.SaveOrUpdate(msg);
                    AddMessage(sheldon, msg, "No, although it’s a question I’ve been pondering since preschool.", time);
                    session.SaveOrUpdate(msg);
                    transaction.Commit();
                }
            }
        }
Ejemplo n.º 5
0
 private static Message AddMessage(Author author, string text, DateTime createdOn)
 {
     var msg = author.AddMessage(new Message() { Text = text, CreatedOn = createdOn });
     return msg;
 }