public ActionResult IndexCreatePOST() { var viewModel = new TagsAdminCreateViewModel(); if (!TryUpdateModel(viewModel)) { ViewData["CreateTag"] = viewModel; return Index(); } _tagService.CreateTag(viewModel.TagName); return RedirectToAction("Index"); }
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); } }
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"); }
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"); }