diff options
Diffstat (limited to 'Project-Unite/Controllers/WikiControllerController.cs')
| -rw-r--r-- | Project-Unite/Controllers/WikiControllerController.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/WikiControllerController.cs b/Project-Unite/Controllers/WikiControllerController.cs index f6b09cd..435e5bd 100644 --- a/Project-Unite/Controllers/WikiControllerController.cs +++ b/Project-Unite/Controllers/WikiControllerController.cs @@ -20,6 +20,18 @@ namespace Project_Unite.Controllers return View(model); } + public ActionResult Random() + { + var db = new ApplicationDbContext(); + var rnd = new Random(); + var index = rnd.Next(0, db.WikiPages.Count()); + if (db.WikiPages.Count() == 0) + return RedirectToAction("Index"); + + var wiki = db.WikiPages.ToArray()[index].Id; + return RedirectToAction("Index", new { id = wiki }); + } + [Authorize] public ActionResult AddPage() { |
