コード例 #1
0
        public ActionResult IndexCreatePOST() {
            var viewModel = new TagsAdminCreateViewModel();

            if (!TryUpdateModel(viewModel)) {
                ViewData["CreateTag"] = viewModel;
                return Index();
            }
            
            _tagService.CreateTag(viewModel.TagName);
            
            return RedirectToAction("Index");
        }
コード例 #2
0
 public ActionResult Create(FormCollection input)
 {
     var viewModel = new TagsAdminCreateViewModel();
     try {
         UpdateModel(viewModel);
         if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
             return new HttpUnauthorizedResult();
         _tagService.CreateTag(viewModel.TagName);
         return RedirectToAction("Index");
     }
     catch (Exception exception) {
         Services.Notifier.Error(T("Creating tag failed: " + exception.Message));
         return View(viewModel);
     }
 }
コード例 #3
0
        public ActionResult IndexCreatePOST() {
            if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Couldn't create tag")))
                return new HttpUnauthorizedResult();

            var viewModel = new TagsAdminCreateViewModel();

            if (!TryUpdateModel(viewModel)) {
                ViewData["CreateTag"] = viewModel;
                return Index();
            }
            
            _tagService.CreateTag(viewModel.TagName);
            
            return RedirectToAction("Index");
        }
コード例 #4
0
        public ActionResult IndexCreatePOST() {
            if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Couldn't create tag")))
                return new HttpUnauthorizedResult();

            var viewModel = new TagsAdminCreateViewModel();

            TryUpdateModel(viewModel);

            if (viewModel.TagName.Intersect(TagsPartDriver.DisalowedChars).Any()) {
                ModelState.AddModelError("_FORM", T("The tag \"{0}\" could not be added because it contains forbidden chars: {1}", viewModel.TagName, String.Join(", ", TagsPartDriver.DisalowedChars)));
            }

            if(!ModelState.IsValid) {
                ViewData["CreateTag"] = viewModel;
                return Index();
            }

            _tagService.CreateTag(viewModel.TagName);
            
            return RedirectToAction("Index");
        }