summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-06 11:38:15 -0400
committerMichael <[email protected]>2017-04-06 11:38:15 -0400
commit687d62912c9eea205306df17422dbdba718344a8 (patch)
treefd3113f84bc55544fb66d1f44c841c665f98d903
parent1f6ab0dbbe9bf186652ce010cbb0ee11697ff451 (diff)
downloadproject-unite-687d62912c9eea205306df17422dbdba718344a8.tar.gz
project-unite-687d62912c9eea205306df17422dbdba718344a8.tar.bz2
project-unite-687d62912c9eea205306df17422dbdba718344a8.zip
add get/post for addwikicategory
-rw-r--r--Project-Unite/Controllers/DeveloperController.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/DeveloperController.cs b/Project-Unite/Controllers/DeveloperController.cs
index 9e3d6c0..f656132 100644
--- a/Project-Unite/Controllers/DeveloperController.cs
+++ b/Project-Unite/Controllers/DeveloperController.cs
@@ -140,6 +140,54 @@ namespace Project_Unite.Controllers
var cats = db.WikiCategories;
return View(cats);
}
+
+ public ActionResult AddWikiCategory()
+ {
+ if (!ACL.Granted(User.Identity.Name, "CanAccessDevCP"))
+ return new HttpStatusCodeResult(403);
+
+ var mdl = new AddWikiCategoryViewModel();
+ return View(mdl);
+
+ }
+
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public ActionResult AddWikiCategory(AddWikiCategoryViewModel model)
+ {
+ if (!ACL.Granted(User.Identity.Name, "CanAccessDevCP"))
+ return new HttpStatusCodeResult(403);
+
+ if (!ModelState.IsValid)
+ return View(model);
+
+ var db = new ApplicationDbContext();
+ var cat = new WikiCategory();
+
+ var new_id = model.Name.ToLower();
+
+ foreach(var c in new_id.ToArray())
+ {
+ if(c == '.' || !ApprovedIdChars.Contains(c))
+ {
+ new_id = new_id.Replace(c, '_');
+ }
+ }
+
+ cat.Id = new_id;
+ cat.Name = model.Name;
+
+ cat.Parent = model.ParentId;
+
+ db.WikiCategories.Add(cat);
+ db.SaveChanges();
+
+ return RedirectToAction("Wiki");
+
+
+
+ }
+
}