public void AddVote(int userId, int pageId, bool vote) { var userVote = _db.PageVotes.FirstOrDefault(c => c.UserId == userId && c.PageID == pageId); if (userVote != null) { userVote.Vote = vote; } else { userVote = new PageVote() { PageID = pageId, UserId = userId, Vote = vote }; _db.Add(userVote); } _db.SaveChanges(); }
/// <summary> /// Sets the current page. /// </summary> protected override void SetCurrentPage() { //Create master page MasterPage = new PageMaster(this); //Create whatever other page currently selected switch (Page) { case 1: { CurrentPage = new PageOverview(this); break; } case 2: { CurrentPage = new PageFinance(this); break; } case 3: { CurrentPage = new PagePopulace(this); break; } case 4: { CurrentPage = new PageDelegation(this); break; } case 5: { CurrentPage = new PageVote(this); break; } } }