Пример #1
0
        private void AddNewQuestion(Window window)
        {
            Random rand = new Random();
            Task   task = new Task(() =>
            {
                BadgeCollection Badges = new BadgeCollection()
                {
                    GoldenBadges = rand.Next(0, 10),
                    SilverBadges = rand.Next(0, 50),
                    BronzeBadges = rand.Next(0, 200)
                };

                User Owner = new User()
                {
                    Name       = questionAuthor,
                    Reputation = rand.Next(0, 10000),
                };
                Owner.BadgeCollection = Badges;

                Topic newTopic = new Topic()
                {
                    Title        = questionTitle,
                    Content      = questionContent,
                    StringTags   = questionTags,
                    VoteCount    = rand.Next(0, 100),
                    AnswerCount  = rand.Next(0, 50),
                    ViewCount    = rand.Next(0, 10000),
                    CreationDate = 0
                };
                newTopic.User = Owner;

                DataBaseRepository.AddNewTopic(newTopic);
            });

            task.Start();

            if (window != null)
            {
                window.Close();
            }
        }