diff options
| author | Michael <[email protected]> | 2017-04-06 11:38:15 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-06 11:38:15 -0400 |
| commit | 687d62912c9eea205306df17422dbdba718344a8 (patch) | |
| tree | fd3113f84bc55544fb66d1f44c841c665f98d903 | |
| parent | 1f6ab0dbbe9bf186652ce010cbb0ee11697ff451 (diff) | |
| download | project-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.cs | 48 |
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"); + + + + } + } |
