mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-02-02 13:07:34 +00:00
"Random page" link in wiki
This commit is contained in:
parent
e28195596b
commit
1675a18905
2 changed files with 22 additions and 0 deletions
|
@ -20,6 +20,18 @@ namespace Project_Unite.Controllers
|
||||||
return View(model);
|
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]
|
[Authorize]
|
||||||
public ActionResult AddPage()
|
public ActionResult AddPage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,12 +26,22 @@
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (Request.IsAuthenticated)
|
||||||
|
{
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li><a href="@Url.Action("AddPage")"><span class="glyphicon glyphicon-plus"></span> Add new page.</a></li>
|
||||||
|
</ul>
|
||||||
|
}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-4 panel">
|
<div class="col-xs-4 panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h4>Pages</h4>
|
<h4>Pages</h4>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>@Html.ActionLink("Index", "Index")</li>
|
||||||
|
<li>@Html.ActionLink("Random page", "Random")</li>
|
||||||
|
|
||||||
@foreach(var cat in Model.Categories)
|
@foreach(var cat in Model.Categories)
|
||||||
{
|
{
|
||||||
@CreateCategoryListRecursive(cat);
|
@CreateCategoryListRecursive(cat);
|
||||||
|
|
Loading…
Add table
Reference in a new issue