示例#1
0
        // POST: api/Subforums
        public void Post(object subforum)
        {
            Subforum sub = JsonConvert.DeserializeObject <Subforum>(subforum.ToString());

            Models.Models.Subforums.Add(sub);
            serializer.SerializeObject(Models.Models.Subforums, "Subforums");
        }
        public async Task <IActionResult> DeleteSubforum(int subforumId)
        {
            Subforum forumToDelete = await _Repo.Subforums.FirstOrDefaultAsync(x => x.Id == subforumId);

            _Repo.Delete(forumToDelete);
            await _Repo.SaveChangesAsync();

            return(await GetForumsAsync());
        }
示例#3
0
        public async Task CreateAsync(string name, int categoryId)
        {
            var subforumExists = await this.db.Subforums.AnyAsync(sf => sf.Name == name);

            if (!subforumExists)
            {
                var subforum = new Subforum {
                    Name = name, CategoryId = categoryId
                };
                this.db.Subforums.Add(subforum);
                await this.db.SaveChangesAsync();
            }
        }
示例#4
0
        // PUT: api/Subforums/5
        public void Put(int id, object subforum)
        {
            Subforum sub = JsonConvert.DeserializeObject <Subforum>(subforum.ToString());

            if (Models.Models.Subforums.Where(x => x.Id == sub.Id).FirstOrDefault() != null)
            {
                Models.Models.Subforums[Models.Models.Subforums.FindIndex(x => x.Id == id)] = sub;
            }
            else
            {
                Models.Models.Subforums.Add(sub);
            }
            serializer.SerializeObject(Models.Models.Subforums, "Subforums");
        }
示例#5
0
        public ActionResult CreateSubForum(CreateSubForumViewModel model)
        {
            if (model.Name == null || (model.Name = model.Name.Trim()) == "" || model.Name.Any(ch => (!char.IsLetterOrDigit(ch) && !char.IsWhiteSpace(ch))))
            {
                return(View());
            }


            //if modelstate is valid
            if (ModelState.IsValid)
            {
                //create subforum off model
                var subforum = new Subforum {
                    Name = model.Name
                };

                //get all subforums in db
                var currentsubforums = db.Subforums.ToList();
                // the subforum id we are going to assign
                int newId = 1;
                //loop through subforums
                foreach (Subforum s in currentsubforums)
                {
                    ++newId;
                    //if existing subforum name equals subforum name to be inserted
                    if (s.Name == subforum.Name)
                    {
                        //display error
                        ViewBag.CreateSubForumError = "Subforum name already exists";
                        //return view with error messages
                        return(View(model));
                    }
                }
                //attempt to insert into db
                try {
                    subforum.SubforumID = newId;
                    db.Subforums.Add(subforum);
                    db.SaveChanges();
                } catch {
                    ViewBag.CreateSubForumError = "Error inserting name into database, try again";
                    //return view with error messages
                    return(View(model));
                }
                //redirect subforum view
                return(RedirectToAction("Index", new { tag = subforum.Name }));
            }
            //if modelstate failed, return view with error messages
            return(View(model));
        }
示例#6
0
        // POST: api/Topics
        //public void Post(object topic)
        //{


        //}

        // PUT: api/Topics/5
        public void Put(int id, object topic)
        {
            Topic    top = JsonConvert.DeserializeObject <Topic>(topic.ToString());
            Subforum sub = Models.Models.Subforums.Where(x => x.Id == id).FirstOrDefault();

            if (sub.Topics.Where(x => x.Id == top.Id).FirstOrDefault() != null)
            {
                sub.Topics[sub.Topics.FindIndex(x => x.Id == top.Id)] = top;
            }
            else
            {
                sub.Topics.Add(top);
            }
            serializer.SerializeObject(Models.Models.Subforums, "Subforums");
        }
示例#7
0
 static void CreateComment(Random random, string text, string authorUsername, Subforum sub, int index)
 {
     sub.Topics[index].Comments.Add(new Comment()
     {
         Id               = random.Next(),
         Text             = text,
         TopicId          = sub.Topics[index].Id,
         CreationDate     = DateTime.Now,
         AuthorUsername   = authorUsername,
         ChildrenComments = new List <Comment>(),
         UsersWhoVoted    = new List <string>(),
         DislikesNo       = 0,
         LikesNo          = 0,
         Edited           = false,
         Removed          = false
     });
 }
示例#8
0
        // DELETE: api/Topics/5
        public IHttpActionResult Delete(int id)
        {
            var temp = from subforum in Models.Models.Subforums
                       from top in subforum.Topics
                       where top.Id == id
                       select subforum;

            Subforum sub = temp.ToList().FirstOrDefault();

            if (sub.Topics.Where(x => x.Id == id).FirstOrDefault() == null)
            {
                return(BadRequest("Topic is already deleted."));
            }
            sub.Topics.Remove(sub.Topics.Where(x => x.Id == id).FirstOrDefault());
            serializer.SerializeObject(Models.Models.Subforums, "Subforums");
            return(Ok("Topic is deleted."));
        }
        public async Task <IActionResult> CreateSubforum(CreateSubforumDTO createSubforumDTO)
        {
            var forum = await _Repo.Forums.FirstOrDefaultAsync(x => x.Id == createSubforumDTO.ForumId);

            var newSubforum = new Subforum
            {
                Title       = createSubforumDTO.Title,
                Slug        = createSubforumDTO.Title.GenerateSlug(),
                Description = createSubforumDTO.Description ?? string.Empty,
                Icon        = createSubforumDTO.Icon ?? string.Empty,
                ForumFK     = forum.Id,
                Forum       = forum
            };

            _Repo.Add(newSubforum);
            await _Repo.SaveChangesAsync();

            return(await GetForumsAsync());
        }
        // GET: api/Complaints/5
        public List <Complaint> Get(string useRole)
        {
            string[]         userAndRole = useRole.Split('-');
            List <Complaint> complaints  = new List <Complaint>();
            bool             outOfLoop   = false;

            foreach (var complaint in Models.Models.Complaints)
            {
                if (complaint.EntityType == EntityType.Subforum)
                {
                    if (LieabilityCheck(userAndRole[0], userAndRole[1], string.Empty))
                    {
                        complaints.Add(complaint);
                    }
                }
                else if (complaint.EntityType == EntityType.Topic)
                {
                    Subforum subforum = Models.Models.Subforums.Where(x => x.Topics.Where(y => y.Id == complaint.EntityId).FirstOrDefault() ==
                                                                      x.Topics.Where(y => y.Id == complaint.EntityId).FirstOrDefault()).FirstOrDefault();
                    if (LieabilityCheck(userAndRole[0], userAndRole[1], subforum.LeadModeratorUsername))
                    {
                        complaints.Add(complaint);
                    }
                }
                else
                {
                    foreach (var subforum in Models.Models.Subforums)
                    {
                        foreach (var topic in subforum.Topics)
                        {
                            foreach (var item in topic.Comments)
                            {
                                if (item.Id == complaint.EntityId)
                                {
                                    if (LieabilityCheck(userAndRole[0], userAndRole[1], subforum.LeadModeratorUsername))
                                    {
                                        complaints.Add(complaint);
                                        outOfLoop = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (FindComment(item.ChildrenComments, complaint.EntityId))
                                    {
                                        if (LieabilityCheck(userAndRole[0], userAndRole[1], subforum.LeadModeratorUsername))
                                        {
                                            complaints.Add(complaint);
                                            outOfLoop = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (outOfLoop == true)
                            {
                                break;
                            }
                        }
                        if (outOfLoop == true)
                        {
                            outOfLoop = false;
                            break;
                        }
                    }
                }
            }
            return(complaints);
        }
示例#11
0
 static void CreateTopic(Random random, string name, string authorUsername, TopicType topicType, string content, Subforum sub)
 {
     sub.Topics.Add(new Topic()
     {
         Id             = random.Next(),
         SubforumId     = sub.Id,
         Name           = name,
         AuthorUsername = authorUsername,
         TopicType      = topicType,
         Content        = content,
         CreationDate   = DateTime.Now,
         LikesNum       = 2,
         DislikesNum    = 0,
         Comments       = new List <Comment>(),
         UsersWhoVoted  = new List <string>()
         {
             "borba", "kec"
         }
     });
 }
示例#12
0
        static void Main(string[] args)
        {
            DataIO serializer = new DataIO();
            Random random     = new Random((int)DateTime.Now.Ticks);

            AppUsers.Add(new AppUser()
            {
                Id                  = random.Next(),
                Name                = "admin",
                Surname             = "admin",
                UserName            = "******",
                ContactPhone        = "021/12345",
                Email               = "*****@*****.**",
                Password            = "******",
                Role                = "Admin",
                RegistrationDate    = DateTime.Now,
                BookmarkedSubforums = new List <string>(),
                ReceivedMessages    = new List <Message>()
                {
                    new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "Bem ti lebac"
                    }, new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "aaaaaaaaa"
                    }
                },
                SavedComments = new List <Comment>(),
                SavedTopics   = new List <Topic>()
            });
            AppUsers.Add(new AppUser()
            {
                Id                  = random.Next(),
                Name                = "mica",
                Surname             = "micic",
                UserName            = "******",
                ContactPhone        = "021/12345",
                Email               = "*****@*****.**",
                Password            = "******",
                Role                = "Moderator",
                RegistrationDate    = DateTime.Now,
                BookmarkedSubforums = new List <string>(),
                ReceivedMessages    = new List <Message>()
                {
                    new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "Bem ti lebac"
                    }, new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "aaaaaaaaa"
                    }
                },
                SavedComments = new List <Comment>(),
                SavedTopics   = new List <Topic>()
            });
            AppUsers.Add(new AppUser()
            {
                Id                  = random.Next(),
                Name                = "Aleksandar",
                Surname             = "Misljenovic",
                UserName            = "******",
                Email               = "*****@*****.**",
                Password            = "******",
                Role                = "AppUser",
                ContactPhone        = "021/1353545",
                RegistrationDate    = DateTime.Now,
                BookmarkedSubforums = new List <string>(),
                ReceivedMessages    = new List <Message>()
                {
                    new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "opassada"
                    }, new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "ajsasa"
                    }
                },
                SavedComments = new List <Comment>(),
                SavedTopics   = new List <Topic>()
            });

            AppUsers.Add(new AppUser()
            {
                Id                  = random.Next(),
                Name                = "Moderator",
                Surname             = "Moderator",
                ContactPhone        = "021/8778585",
                UserName            = "******",
                Email               = "*****@*****.**",
                Password            = "******",
                Role                = "Moderator",
                RegistrationDate    = DateTime.Now,
                BookmarkedSubforums = new List <string>(),
                ReceivedMessages    = new List <Message>()
                {
                    new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "mhmhm"
                    }, new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "frik"
                    }
                },
                SavedComments = new List <Comment>(),
                SavedTopics   = new List <Topic>()
            });

            AppUsers.Add(new AppUser()
            {
                Id                  = random.Next(),
                Name                = "Aleksandar",
                Surname             = "Misljenovic",
                UserName            = "******",
                Email               = "*****@*****.**",
                Password            = "******",
                Role                = "AppUser",
                ContactPhone        = "021/1353545",
                RegistrationDate    = DateTime.Now,
                BookmarkedSubforums = new List <string>(),
                ReceivedMessages    = new List <Message>()
                {
                    new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "opassada"
                    }, new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "ajsasa"
                    }
                },
                SavedComments = new List <Comment>(),
                SavedTopics   = new List <Topic>()
            });

            AppUsers.Add(new AppUser()
            {
                Id                  = random.Next(),
                Name                = "Aleksandar",
                Surname             = "Misljenovic",
                UserName            = "******",
                Email               = "*****@*****.**",
                Password            = "******",
                Role                = "AppUser",
                ContactPhone        = "021/1353545",
                RegistrationDate    = DateTime.Now,
                BookmarkedSubforums = new List <string>(),
                ReceivedMessages    = new List <Message>()
                {
                    new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "opassada"
                    }, new Message {
                        Id = random.Next(), SenderUsername = "******", Content = "ajsasa"
                    }
                },
                SavedComments = new List <Comment>(),
                SavedTopics   = new List <Topic>()
            });

            CreateSubforum(random, "Funny", "hot topics", "do w/e", "moderator", "http://localhost:54042/Content/Icons/icon-0.ico");
            CreateSubforum(random, "World", "controversial topics", "w/e", "mica", "http://localhost:54042/Content/Icons/icon-1.ico");
            CreateSubforum(random, "Movies", "new topics", "w/e", "mica", "http://localhost:54042/Content/Icons/icon-2.ico");
            CreateSubforum(random, "Gaming", "opular topics", "w/e", "moderator", "http://localhost:54042/Content/Icons/icon-3.ico");
            Subforum sub = Subforums[0];

            CreateTopic(random, "Topic 1",
                        "mica", TopicType.Text, "test test", Subforums[0]);
            CreateTopic(random, "Topic 2", "mica", TopicType.Text, "test test", Subforums[1]);
            CreateTopic(random, "Topic 3", "mica", TopicType.Text, "test test", Subforums[2]);
            CreateTopic(random, "Topic 4", "mica", TopicType.Text, "test test", Subforums[3]);
            CreateTopic(random, "Topic 5 ", "mica", TopicType.Text, "test test", Subforums[0]);
            CreateTopic(random, "Topic 8", "mica", TopicType.Text, "test test", Subforums[0]);
            CreateTopic(random, "Topic 7", "mica", TopicType.Text, "test test", Subforums[1]);
            CreateTopic(random, "Topic 8", "mica", TopicType.Text, "test test", Subforums[2]);
            CreateTopic(random, "Topic 6", "mica", TopicType.Text, "test test", Subforums[3]);

            CreateComment(random, "jedan", "mica", Subforums[0], 0);
            CreateComment(random, "dva", "mica", Subforums[1], 1);
            CreateComment(random, "tri", "mica", Subforums[2], 1);
            CreateComment(random, "cetiri", "mica", Subforums[3], 1);
            CreateComment(random, "pet", "aca", Subforums[0], 1);
            CreateComment(random, "sest", "aca", Subforums[1], 1);
            CreateComment(random, "sedam", "aca", Subforums[2], 1);
            CreateComment(random, "osam", "aca", Subforums[3], 1);
            CreateComment(random, "devet", "aca", Subforums[0], 0);
            CreateChildComment(random, "deset", "aca", Subforums[0], 0, Subforums[0].Topics[0].Comments[0].Id);
            CreateComplaint(random, "zzzzzzzzzz", EntityType.Comment, Subforums[0].Topics[0].Comments[0].Id, Subforums[0].Topics[0].Comments[0].TopicId, Subforums[0].Topics[0].Comments[0].AuthorUsername, "aca");
            CreateComplaint(random, "bbbbbbbbbb", EntityType.Subforum, Subforums[0].Id, -1, Subforums[0].LeadModeratorUsername, "aca");
            CreateComplaint(random, "kkkkkkkkkk", EntityType.Topic, Subforums[0].Topics[0].Id, -1, Subforums[0].Topics[0].AuthorUsername, "aca");

            serializer.SerializeObject(AppUsers, "AppUsers");
            serializer.SerializeObject(Complaints, "Complaints");
            serializer.SerializeObject(Subforums, "Subforums");
        }
示例#13
0
        public static void SeedData(DataContext context, RoleManager <Role> roleManager, UserManager <User> userManager)
        {
            if (!roleManager.Roles.Any())
            {
                List <Role> roles = new List <Role>()
                {
                    new Role()
                    {
                        Name = "Administrator"
                    },
                    new Role()
                    {
                        Name = "Moderator"
                    },
                    new Role()
                    {
                        Name = "Member"
                    },
                    new Role()
                    {
                        Name = "Guest"
                    }
                };

                foreach (var role in roles)
                {
                    roleManager.CreateAsync(role);
                }
            }

            if (!userManager.Users.Any())
            {
                User newAdmin = new User()
                {
                    DisplayName = "Bob the Magnificent",
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    JoinDate    = DateTime.Now
                };

                userManager.CreateAsync(newAdmin, "password");
                userManager.AddToRolesAsync(newAdmin, new string[] { "Member", "Moderator", "Administrator" });
            }

            if (context.Forums.Any())
            {
                return;
            }

            Forum[] forums = new Forum[]
            {
                new Forum()
                {
                    Title = "My Digital Life", Description = ""
                },
                new Forum()
                {
                    Title = "Software And Modifications", Description = ""
                },
                new Forum()
                {
                    Title = "Gadget And Hardware Life", Description = ""
                }
            };

            context.Forums.AddRange(forums);
            context.SaveChanges();

            Subforum[] subforums = new Subforum[]
            {
                new Subforum()
                {
                    Title = "Announcements", Description = "", Icon = "bullhorn", ForumFK = 1
                },
                new Subforum()
                {
                    Title = "Giveaways and Contests", Description = "", Icon = "gift", ForumFK = 1
                },
                new Subforum()
                {
                    Title = "BIOS Mods", Description = "", Icon = "magic", ForumFK = 2
                },
                new Subforum()
                {
                    Title = "MDL Projects and Applications", Description = "", Icon = "cogs", ForumFK = 2
                },
                new Subforum()
                {
                    Title = "Application Software", Description = "", Icon = "link", ForumFK = 2
                },
                new Subforum()
                {
                    Title = "PC Hardware", Description = "", Icon = "wrench", ForumFK = 3
                },
                new Subforum()
                {
                    Title = "Mobile and Portable", Description = "", Icon = "laptop", ForumFK = 3
                },
                new Subforum()
                {
                    Title = "Gaming", Description = "", Icon = "gamepad", ForumFK = 3
                }
            };

            foreach (var item in subforums)
            {
                context.Subforums.Add(item);
                context.SaveChanges();
            }

            int adminId = userManager.FindByNameAsync("Bob").Result.Id;

            Thread[] threads = new Thread[]
            {
                new Thread()
                {
                    Title = "Smilies for our members and guests", Content = "You need to login to view this posts content.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 1, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Emsisoft Anti-Malware 25 x 1-Year/1PC Giveaway#2", Content = "Emsisoft is an award-winning security that protects your devices, your data and your identity without slowing you down.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 2, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Award & AMI Bios mod requests", Content = "You need to login to view this posts content.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 3, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Award & AMI Bios mod requests 2", Content = "You need to login to view this posts content.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 3, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Award & AMI Bios mod requests 3", Content = "You need to login to view this posts content.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 3, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "MSMG ToolKit", Content = "You need to login to view this posts content.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 4, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Use Office Tool to download, install, manage and activate Office 2016, 2019 and 365", Content = "You need to login to view this posts content.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 5, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Marvell Controller Card Issues", Content = "I have an IOCrest card (I/O Crest 8 Port SATA III PCIe 2.0 x2 Non RAID Controller Card) and it's recently started dropping the drives attached to it when I copy data to or from one of the drives connected to it (non-RAID).", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 6, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Huawei and Trump Ban", Content = "I have the Huawei Y6 Pro 2019 and Huawei Media pad Tablet. Both are good.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 7, AuthorId = adminId
                },
                new Thread()
                {
                    Title = "Games will not start in windows 10", Content = "I can install hidden object games. that worked in windows 7,8 but not 10. no errors come up", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, SubforumFK = 8, AuthorId = adminId
                }
            };

            foreach (var thread in threads)
            {
                context.Threads.Add(thread);
                context.SaveChanges();
            }

            Post[] posts = new Post[]
            {
                new Post()
                {
                    Content = "Can someone please reupload these? Thanks!", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 1, AuthorId = adminId
                },
                new Post()
                {
                    Content = "I'm currently using Kaspersky on my another computer and i'd love to use EAM on my new PC.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 2, AuthorId = adminId
                },
                new Post()
                {
                    Content = "I made mine with andyp's ami bios tool and it works!! (default 1.29 settings).", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 3, AuthorId = adminId
                },
                new Post()
                {
                    Content = "Don't run! Says the OS architecture is x86 but it is x64!!!", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 6, AuthorId = adminId
                },
                new Post()
                {
                    Content = "Only Office Tool Lite can install Office 2016 Volume Edition when you are using Install Mode: Office Tool Lite, not Office Deployment Tool, this is right.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 7, AuthorId = adminId
                },
                new Post()
                {
                    Content = "PCI Express x2 interface max 4 Sata III ports, guess thats the problem.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 8, AuthorId = adminId
                },
                new Post()
                {
                    Content = "The products that are sold already are not affected. You still will get updates. Google said they anyway want to do business with Huawei.", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 9, AuthorId = adminId
                },
                new Post()
                {
                    Content = "I assume you tried compatibility mode I run games from 2006-07 and set them to run as administrator I have played old hidden objects games on windows 10 pro 64bit", CreatedOn = DateTime.Now, Edited = false, LastEditDate = DateTime.MinValue, ThreadFK = 10, AuthorId = adminId
                },
            };

            foreach (var post in posts)
            {
                context.Posts.Add(post);
                context.SaveChanges();
            }
        }
示例#14
0
        public Subforum GetSubforum(string name)
        {
            var subforum = new Subforum();

            using (var cmd = _conn.CreateCommand())
            {
                cmd.CommandText =
                    @"SELECT Description, Rules, IconPath, MainModerator
                      FROM Subforums
                      WHERE Name = @name;";
                cmd.Parameters.AddWithValue("@name", name);

                using (var reader = cmd.ExecuteReader())
                {
                    if (!reader.Read())
                    {
                        return(null);
                    }

                    subforum.Name              = name;
                    subforum.Description       = reader.GetString(0);
                    subforum.Rules             = DecodeRules(reader.GetString(1));
                    subforum.IconPath          = reader.GetString(2);
                    subforum.MainModeratorName = reader.GetString(3);
                    subforum.ModeratorNames    = new List <string>();
                    subforum.Themes            = new List <SubforumTheme>();
                }
            }

            using (var cmd = _conn.CreateCommand())
            {
                cmd.CommandText =
                    @"SELECT Moderator
                      FROM Moderators
                      WHERE Subforum = @name;";
                cmd.Parameters.AddWithValue("@name", name);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        subforum.ModeratorNames.Add(reader.GetString(0));
                    }
                }
            }

            using (var cmd = _conn.CreateCommand())
            {
                cmd.CommandText =
                    @"SELECT Title
                      FROM Themes
                      WHERE Subforum = @name;";
                cmd.Parameters.AddWithValue("@name", name);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var title = reader.GetString(0);
                        var votes = GetThemeVotes(name, title);

                        subforum.Themes.Add(new SubforumTheme()
                        {
                            Title         = title,
                            PositiveVotes = votes.Item1,
                            NegativeVotes = votes.Item2
                        });
                    }
                }
            }

            return(subforum);
        }